Issue requesting Access Token with .NET SDK

Hi all,

Some info about my setup first. Working with a Blazor server-side application, running asp.net core 5.0, with latest version of the Auth0 SDK installed. What I am running into and having problems with is requesting an access token to use with the management API.

Current code:

 string auth0Domain = "https://dev-qoess5ks.us.auth0.com/";
            var auth0AuthenticationClient = new AuthenticationApiClient(
                new Uri(String.Format("https://{0}", auth0Domain)));
            
            var tokenRequest = new ClientCredentialsTokenRequest()
            {
                ClientId = "myID",
                ClientSecret = "mySecret",
                Audience = String.Format("https://{0}/api/v2/", auth0Domain),
            };
            var tokenResponse =
                await auth0AuthenticationClient.GetTokenAsync(tokenRequest); // this is where my application times out, not sure if it means incorrect credentials or what.

            return tokenResponse.AccessToken;
        }

Just to check, I am inputting the ClientID and ClientSecret of the ManagementAPI correct? Not that of my current application? I have tried both and come to no avail.

Thanks for your help!

Hey @adavisson, welcome to the Auth0 Community!

After taking a quick look it seems you included all the mandatory parameters as documented on our Authentication API documentation. The question now is: Are they correct? Well, you asked about ClientID and ClientSecret. Those two must belong to the Machine to Machine application that you should have previously created; the M2M application that will be allowed to request Management API Access Tokens. More about this at the very bottom of my response.

You mentioned that your application timed out at some point. If you’d make a similar call via cURL you should be able to determine if the timeout comes from misuse or misconfiguration of your tech stack or maybe you’ll find out that there’s a network issue affecting cURL as well.

My suggestion would be to try to reproduce the issue via cURL. To do this, I encourage you follow our documentation on how to Get Management API Access Tokens for Production.

I hope this helps.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.