500 on /oauth/token machine-to-machine

I want to use manage API to delete user with the endpoint
DELETE /api/v2/users/{id}

I already have machine-to-machine app with all APIs Authorized and delete:users checked in permissions

So I follow this doc to get access token :

but the API returns me HTTP 500 with this body :

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

I try with Insomnia and my project and i’ve got the same result

My code :

RestBuilder rest = new RestBuilder()
        RestResponse response = rest.post("https://tenant-url/oauth/token") {
                grant_type = "client_credentials"
                client_id = "my client id"
                client_secret = "my client secret"
                audience = "https://tenant-url/api/v2/"

I see nothing wrong on status page so why I’ve got a 500 error ?

I had a default hook set in my configuration
Once removed, the error disappeared

The error message is not clear :angry:

1 Like

Hi @t.leduc,

Thanks for reaching out to the Auth0 Community!

I understand that you encountered an undescriptive error when getting the Management API access token.

I’m glad you resolved the issue after discovering that a Client Credentials Exchange Hook was responsible for the error!

In the future, I recommend using our Auth0 Real-time Webtask Logs Extension to troubleshoot all the custom-code on your account.

If you have any other issues or questions, please feel free to reach out.

Thank you.