Unique ID for Users

New to Auth0. Liking it so far.

I have a python flask backend which formerly used a DB table with Users. But now I’m trying to set up Auth0.

How do I create a table or mechanism to identify users with a unique ID?

Can I get a unique ID directly from auth0 in the front end?

Or is there a a way to pull this from the backend?

const { user } = useAuth0() gives me the following. But nothing here is both permanent and unique since user emails do changes.

user = {
email: “john.b.smith@gmail.com”
email_verified: true
family_name: “Smith”
given_name: “John”
locale: “en”
name: “John Smith”
nickname: “john.b.smith”
picture: “https://lh3.googleusercontent.com/a-/AOh14dfrtyuRTYHfYOPGZrL641HkQoNqd=s96-c”
sub: “google-oauth2|113456789076”
updated_at: “2020-11-12T14:40:20.297Z”
}

Thanks.

Hi @alej.canizales,

Welcome to the Community!

You can use the sub claim as the user identifier. This value is the Auth0 user_id you see in the dashboard.

Hope this helps,
Dan

Hi Dan. Thank you.

Is there a way my back end can pull a users table directly for Auth0, without having to consult the front end for any tokens? Of course, this would have to be updated frequently but it might be useful.

@alej.canizales,

Can you elaborate on this? What are you pulling from the user and what info are you adding to your backend? You can use the management API to make changes to your users in auth0, including reading their data, but you might not need to do this constantly if you can avoid it.

I’m thinking of pulling all my users data, like that json, into a table. Each json is a row, every property a column.

I see. You can also create a row with the data when the user is created, and update if the id token does not match the table when a new id token is issued, this will save you extra calls as you will already be requesting an id token for the application.

1 Like

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