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.