Auth0 Home Blog Docs

Isue with auth0-java calling the userinfo endpoint



I had some previous code, however after updating to the latest Auth0 java client, I can no longer:

  1. Do a server sided password login;
  2. Use that to retrieve the user_metadata

The current code I am using is (in a test btw)

    AuthAPI auth0 = new AuthAPI(domain, clientId, clientSecret);

    TokenHolder tokenHolder = auth0.login(user, pass)

    String token = tokenHolder.getAccessToken();
    UserInfo profile = auth0.userInfo(token).execute();


And the error I get at line:

    UserInfo profile = auth0.userInfo(token).execute();


   com.auth0.exception.APIException: Request failed with status code 401: invalid credentials
at example.Auth0Tests.TestToken(

I can’t figure out what I need to change to get this to work… What am I doing wrong? Previously I had no issues.


Based on the information available the likely cause is that the access token being issued is not valid to call the /userinfo endpoint. In particular, this may be due to that fact that you’re not specifying a scope parameter containing the openid value so that the request is handled in accordance to OpenID Connect.

In addition, the API associated with the audience you’re providing needs to be using RS256 as the signing algorithm. You can read more about the possible causes for the behavior you’re seeing at: