# Obtaining an authenticated user's id with React

**URL:** <https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069>\
**Category:** Get Help\
**Created:** [May 2, 2021, 2:52am UTC](https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069 "2021-05-02T02:52:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vedaantv](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vedaantv/32/29169_2.png) [@vedaantv](https://community.auth0.com/u/vedaantv)\
**Post date:** [May 2, 2021, 2:52am UTC](https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069/1 "2021-05-02T02:52:41Z")

</div>

Hello, I am attempting to use an authenticated user’s id for verification purposes for something outside of Auth0, but haven’t been able to obtain the data.

I am able to access the user’s email through the following and access it through the state, but I am unable to access the user’s id. Am I missing something?

if (isAuthenticated) {  
setMail(user.email)  
console.log(user.user\_id)  
}

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [May 3, 2021, 3:16pm UTC](https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069/3 "2021-05-03T15:16:18Z")

</div>

Hi @vedaantv,

Welcome to the Community!

When you use `const { user } = useAuth0();` the `user` object is the same as the decoded ID Token payload. Here is an example ID Token: [ID Token Structure](https://auth0.com/docs/tokens/id-tokens/id-token-structure#sample-id-token)

The user’s ID is the `sub` claim. You can log it like this: `console.log(user.sub)`

---

<div class="post-metadata">

**Author:** ![vedaantv](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vedaantv/32/29169_2.png) [@vedaantv](https://community.auth0.com/u/vedaantv)\
**Post date:** [May 3, 2021, 6:18pm UTC](https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069/4 "2021-05-03T18:18:53Z")

</div>

Thank you, this worked!

---

<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 18, 2021, 6:19pm UTC](https://community.auth0.com/t/obtaining-an-authenticated-users-id-with-react/62069/5 "2021-05-18T18:19:00Z")

</div>

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