Auth0 will be maintaining my apps users but I need an identifier to go in the application database to connect user date to. I wanted to use user_id but couldn’t figure out how to get it. email is available but I’m wondering if that could change if the user is able to change the email associated with their account.
Which is the best field to keep in the apps database?
How can I get user_id?
I see user_id there. Don’t know how I missed it before.
Is there significance to the ‘auth0|’ part. Do you recommend keeping that part of the string or parsing it out?
Today I’m getting the below. Haven’t changed the code nor made a configuration change to the Auth0 client. It’s the same console.log statement as yesterday. I’ll move forward using ‘sub’.
Your code snippet shows two different things, or let’s say, have two different origins. One is the excerpt you probably got from the Auth0 Dashboard > Users > User Profile > Raw JSON.
The latest is an ID Token (JWT) payload.
The user_id in the user profile in the Auth0 dashboard is the equivalent to the sub claim in the JWT ID Token.
In your client application that receives the ID token, this sub claim inside the token payload is what you’re looking for and want to use as a reference.
If you’re using the management API to fetch users, you’d use the user_id attribute instead for any look ups based on that.