I can successfully generate an access token using the AuthenticationApiClient but when I try and make a call using the ManagementApiClient I get an error invalid token, unauthorized.
I have added read:users permission on the api, machine to machine tab.
I have also read some other posts on this same issue, but I cant get it to work.
Here is my sample code in c#:
var authUri = new Uri($“https://{authDomain}/”);
var authenticationApiClient = new AuthenticationApiClient(authUri);
var tokenRequest = new ClientCredentialsTokenRequest
{
ClientId = clientId,
ClientSecret = clientSecret,
Audience = audience
};
var token = await authenticationApiClient.GetTokenAsync(tokenRequest);
var client = new ManagementApiClient(token.AccessToken, new Uri($“https://{authDomain}/api/v2”));
var user = await client.Users.GetAsync(authUserId);