Custom Claims added to accessToken not being returned from /userinfo

Hi @alexandra1,

Welcome to the Auth0 Community!

I understand that you have added custom claims to an access token but were not able to see them in the token.

After looking closely at the code snippet you shared, I noticed that you are calling the /userinfo endpoint with the token you obtained from the login flow. In this situation, the audience parameter was never passed in the login request which results in opaque access tokens.

These tokens do not contain custom claims.

To get the custom claims, you must specify an API identifier in the login request as your audience query parameter.

For example:

https://{yourDomain}/authorize?
    response_type=code&
    client_id={yourClientId}&
    redirect_uri={https://yourApp/callback}&
    scope={scope}&
    audience={apiAudience}&
    state={state}

After the login flow is complete, the access token returned can be decoded in jwt.io to see the custom claims.

I hope the explanation was clear! Here are some helpful resources worth checking out:

Please reach out if you have questions or need further clarification.

Thanks,
Rueben