Client Credentials Grant - 500 Error

Could you advise on the following? I’m trying to use postman to get a token with the following url/object but I’m receiving a 500 in response.

Url: https://easywebstore.eu.auth0.com/oauth/token

{
"grant_type":"client_credentials",
"client_id":"[My client id]",
"client_secret":"[My client secret]",
"audience":"https://easywebstore.eu.auth0.com/api/v2/"
}

Response:

{
    "error": "server_error",
    "error_description": "Script generated an unhandled asynchronous exception."
}

I’ve checked Auth0 Management API and confirm that the Inventory Api is Authorized and all the grants in the scope are checked.

Ultimately, I want to get a token so this client can then get all users.

I noticed that under Dashboard → Clients, the client I’m trying to authenticate is a “Regular Web Application” and not a “Non Interactive”. But then when I go to Dashboard → APIs → Auth0 Management API → Non Interactive Clients, my client is listed there. So I’m assuming my client is both a regular web app and a non interactive client and should therefore be able to authenticate with a client credentials grant. Please let me know if this is not the case.

I’ve also checked Clients → My Client → Advanced Settings → Grants Types. My client has the Grant Type Client Credentials checked.

I just tested the client credentials grant against my own account and had no issues. Given the type of error you’re getting the most likely cause would be that you created a client credentials hook that is throwing an exception.

If you have configured a hook for this exchange then you can use the real-time logs extension and console.log statements in the hook itself to quickly troubleshoot the situation.

Thanks @jmangelo

We are using a hook so I checked the logs and can see that it’s throwing an exception. I fixed the hook so it no longer throws the exception and am now receiving a 200 with the access token as expected.

Many thanks again.

Thanks @jmangelo

We are using a hook so I checked the logs and can see that it’s throwing an exception. I fixed the hook so it no longer throws the exception and am now receiving a 200 with the access token as expected.

Many thanks again.