Can I add email address to the access token when calling an api?

I’m following this guide: The Complete Guide to React User Authentication with Auth0
Everything works, but I need to get a few basic details about the user in the api code, primarily the user’s email address.

I guess my question is:

  • Is there any way to affect the data in the access token retrived here? const { getAccessTokenSilently } = useAuth0(); Can I somehow indicate that I’d like to add the user’s emai added to that token?
  • What is otherwise the preferred method for an api to get more information (such as the user’s email) about the calling user?

Hi @trondhindenes,

Thanks for reaching out to the Auth0 Community.

Yes! I recommend using the Add email to access token rule to add the user’s email address to the access token. Navigate to your Dashboard > Auth0Pipeline > Rules > Create and select the Add email to access token rule.

For the complete list of User Object Properties, take a look at this documentation:

After doing so, you can use the Access Token to access your API that contains information about the user’s email address in the payload.

Please let me know if this addresses your questions.

Thank you.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.