# Auth0 User ID vs. Sub Claim

**URL:** <https://community.auth0.com/t/auth0-user-id-vs-sub-claim/93311>\
**Category:** Get Help\
**Tags:** google, oauth2, auth0\
**Created:** [October 28, 2022, 5:24pm UTC](https://community.auth0.com/t/auth0-user-id-vs-sub-claim/93311 "2022-10-28T17:24:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![filipem](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/filipem/32/13740_2.png) [@filipem](https://community.auth0.com/u/filipem)\
**Post date:** [October 28, 2022, 5:24pm UTC](https://community.auth0.com/t/auth0-user-id-vs-sub-claim/93311/1 "2022-10-28T17:24:07Z")

</div>

Hey folks.

We have an internal discussion I’m hopeful you can help resolve. In the past I have used the value contained in the `sub` claim of the access token as the unique identifier of a user. We use Google oauth, so that value typically looks something like this: `google-apps|john.doe@company.com`. My understanding is that we can rely on that value to be immutable, even if the person’s email change (in which case they would either get a new Google account or have an alias for their email but their id/`sub` claim would remain the same). I have used this value because that’s how I’ve interpreted your recommendation here: [Identify Users](https://auth0.com/docs/manage-users/user-accounts/identify-users)

However, some folks on my team are wary of using a value that includes the email since emails (at least with some providers) may be mutable. So they are recommending using the auth0 internal user id, which I believe is always just a random value like `5f7c8ec7c33c6c004bbafe82`.

So my question is very simple: does it matter? If so, which one should we use?

Thank you!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 21, 2022, 10:57pm UTC](https://community.auth0.com/t/auth0-user-id-vs-sub-claim/93311/3 "2022-12-21T22:57:33Z")

</div>

Hey there @filipem welcome to the community!

I apologize for the delayed response on this one but was combing through our backlog and wanted to respond - Where exactly did you land with this? Were you using the Google [enterprise connection](https://auth0.com/docs/authenticate/identity-providers/enterprise-identity-providers) or standard [social connection](https://marketplace.auth0.com/features/social-connections)?

For future reference, the `sub` claim should look something like `google-apps|117686103243408785895170` rather than using the user’s email. It looks like an issue was fixed at some point where the mapping did point to the email rather than an id.

> [@filipem](#):
>
> So my question is very simple: does it matter? If so, which one should we use?

The complaint was that the email may be too “brittle” - In this particular case either should’ve worked, but perhaps the internal id may have been a slightly better option. The `sub` claim is now improved to include an id as mentioned previously.

Hope this helps!

---

<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:** [January 4, 2023, 10:57pm UTC](https://community.auth0.com/t/auth0-user-id-vs-sub-claim/93311/4 "2023-01-04T22:57:37Z")

</div>

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