Get client_credentials access token for Unit Testing in Python

I need to test the server-side code in my application. I have tried a number of approach and settled on using the client_credentials grant type. My code looks like:

url = ‘https://%s/oauth/token’ % AUTH_DOMAIN
headers = {‘content-type’: ‘application/json’}
parameter = { “grant_type”: “client_credentials”,
“client_id”:AUTH_CLIENT_ID,
“client_secret”: AUTH_CLIENT_SECRET,
“audience”: ‘AUTH0_AUDIENCE’}
responseDICT = json.loads(requests.post(url, json=parameter, headers=headers).text)

I get a ‘Grant type \‘client_credentials\’ not allowed for the client.’ From the dashboard, I go to the Advanced Settings for the application and click on Grant Types. Client Credentials is greyed-out because the Token Auth Endpoint is “none”. The Token Auth Endpoint is also greyed-out and I can’t modify it.

Two questions:

  1. Is the approach sound? I’ve spent quite a bit of time on this, and would like to avoid more dead-ends.
  2. Are the client credentials and token auth endpoint settings greyed-out a permissions error, or am I missing something?

Help much appreciated! I have also tried getting the password access token, but this has also failed. My suspicion is that the problem is in the application settings but as I mentioned above I’m not sure how or if I can set them.

Hi @art2,

I apologize for the delay in response, but I wanted to see if you are still running into this issue.

You should be able to use the client credentials grant unless you are using a SPA or Native app. Can you confirm this is not registered as such?

Thanks,
Dan

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