Invalid_token from authorization and using via management api

I am trying to get auth through the authorization endpoint and then use that token in the management endpoint, but every time I do, I get an invalid_token error. I am using C# through the auth0 nuget packages (auth0, auth0.authorization, auth0.management). I am using .net core 3.1.

How I am getting the token. I have used the restREponse way as well, and have the same results

AuthenticationApiClient authenticationApiClient = new AuthenticationApiClient(new Uri($โ€œ{Authority}โ€));
var request = new ClientCredentialsTokenRequest
{
Audience = $โ€œ{Authority}/api/v2/โ€,
ClientId = ClientId,
ClientSecret = ClientSecret
};
var token = authenticationApiClient.GetTokenAsync(request);
token.Wait();
_apiClient = new ManagementApiClient(token.Result.AccessToken, new Uri($โ€œ{_settings.Auth0.Authority}/api/v2/โ€));

I get the token and the api client seems to fill in just fine, but then when I try to call any endpoint I get an invalid token

_apiClient.Users.CreateAsync(new Auth0.ManagementApi.Models.UserCreateRequest()
{
Email = EmailAddress,
EmailVerified = false,
Password = Password,
Connection = Connection
});

When I use the api token from the api explorer, it works easy peasy but I donโ€™t want to do that for production. So the permissions seem to be right. When I copy and paste the token from my code into the api explorer, I get the same invalid_token, so there must be something wrong with the way I am getting the token, but I cannot figure out what I am doing wrong. I do notice that when I put in a token that I get this way, the allowed scopes section in the api explorer, has no scopes. If there is anything I have left out or any questions you have, please let me know, I am outta ideas.

Hi lovejotd,

Could you message the payload of your token to me to have further investigation? DO NOT send your token to me or post it here.
You can use jwt.io to extract the payload of a jwt token.

I believe this is what you want, let me know if this is wrong

JSON Web Tokens - jwt.io

Was this resolved? Having similar issue. Thanks.

1 Like

I am having similiar issue too. Any help?