Auth0 Home Blog Docs

com.auth0.exception.APIException: Request failed with status code 500: Script generated an unhandled asynchronous exception.

authentication_api
java
token-endpoint

#1

In our dev environment, we are receiving the following exception when trying to request the token from the Auth API based on the audience. This code has been working fine for awhile, but just started failing within the last few weeks only in our dev environment. The code works fine in all our other environments, so I suspect this is something specific to our dev environment setup.

Java Code:

AuthRequest authRequest = authAPI.requestToken(config.audience); 
// Get new access token as the API management token expires 
TokenHolder tokenHolder = authRequest.execute();

Auth0 Exception:

com.auth0.exception.APIException:
Request failed with status code 500:
Script generated an unhandled
asynchronous exception.

Any ideas how to fix this error?


#2

The requestToken method performs a client credentials grant so if you consider that in conjunction with the fact that you say that this only happens in one of your environment the most likely cause is that you have a client credentials hook configured in that environment that is causing an error and leading to the overall grant to fail.

The theory above is made stronger due to the type of the error, in particular, the mention of a Script which suggests that a custom extensibility point that allows to provide custom scripts is being used.

The recommendation would be to review the hooks you have in place.


#3

Thanks for the suggestion @jmangelo ! When you say review the hooks we have in place, what do you mean by that and where can I check that setup within Auth0? Thanks!


#4

Thanks for the suggestion @jmangelo ! When you say review the hooks we have in place, what do you mean by that and where can I check that setup within Auth0? Thanks!


#5

In the Auth0 Dashboard, on the left side navigation pane there should be a Hooks entry below Rules, you can check there if there are hooks enabled in the account and also check their logic.


#6