# Passing user data from the initial authentication on to an API all

**URL:** <https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528>\
**Category:** Get Help\
**Tags:** jwt, auth0\
**Created:** [April 21, 2021, 11:53pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528 "2021-04-21T23:53:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OliDow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/olidow/32/28946_2.png) [@OliDow](https://community.auth0.com/u/OliDow)\
**Post date:** [April 21, 2021, 11:53pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528/1 "2021-04-21T23:53:43Z")

</div>

Hi

I am new to Auth0 and I’m sure I am missing something obvious but having issues related to getting profile information when calling an API.

My aim is to be able to authenticate with Auth0 (with an Auth0 user or a social provider) then pass the basic profile and email claims in the JWT when sending requests to an API.

When doing the initial authentication (scope: “openid profile email”) I am presented with the profile information I need, however when I call

` getAccessTokenSilently({scope: "openid profile email"})`

I get a accesstoken JWT that is very bare and does not include any of the profile data.

` {"iss":"https://xxx.eu.auth0.com/","sub":"google-oauth2|123["http://localhost:3000","https://xxx.eu.auth0.com/userinfo"],"iat":1619047752,"exp":16191300004152,"azp":"S311aHK71RV9qvnfrxNM3ONKqNnaS1k6","scope":"openid profile email"}`

1. Am I doing something unusual and should my process be realigned?
2. If no to the above then how do I enrich the token with the profile and email data?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 22, 2021, 4:56pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528/3 "2021-04-22T16:56:53Z")

</div>

Hi @OliDow,

Welcome to the Community and to Auth0!

You can use the ID token for user profile, or exchange the access token to the /userinfo endpoint for the user profile.

Depending on where you want this info, you can choose which one of those options suits you.

---

<div class="post-metadata">

**Author:** ![OliDow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/olidow/32/28946_2.png) [@OliDow](https://community.auth0.com/u/OliDow)\
**Post date:** [April 22, 2021, 10:06pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528/4 "2021-04-22T22:06:34Z")

</div>

Hi Dan

Thanks for the quick reply.

I need the user profile information on the API being called.

1. Am I able to do this exchange client side? Enrich the token sent to the API (second code block in the OP) with the information form the User token?  
or
2. Would the best practice be to call the /userinfo endpoint you mentioned directly from the endpoint after it is called?

I guess I am just curious of what your the best practice is for getting claims from the initial first time authentication available on API endpoints being called.

Thanks again

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 23, 2021, 3:23pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528/5 "2021-04-23T15:23:02Z")

</div>

The tokens are immutable. If you change anything in it then the signature will no longer match the payload and you cannot validate the token.

You are probably best off calling the /userinfo endpoint to get the user’s profile from your backend API.

This doc does a good job of explaining the differences between the two and their uses.

[https://auth0.com/docs/tokens](https://auth0.com/docs/tokens)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 8, 2021, 3:23pm UTC](https://community.auth0.com/t/passing-user-data-from-the-initial-authentication-on-to-an-api-all/61528/6 "2021-05-08T15:23:14Z")

</div>

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