How user_id at auth0 created

How auth0 form a unique id as user_id when new user is created at auth0. What is the procedure they follow to create this ID. I need similar unique Id like this in user profile.

Hi @rashid779939,

I don’t know the exact details / code of the algorithm for setting up the user_id, but it is usually of the form:

[identity-provider]|[identity-provider-unique-identifier]

For example:

google-apps|jane.doe@foo.com        # G Suite user
google-oauth2|jane.doe@foo.com      # Google social login
auth0|jane.doe@foo.com              # users stored in Auth0.

You can use this field as a unique identifier, or you can add your own to the user’s metadata. You can create your own unique ID using a Rule.

2 Likes

If you are interested, here’s a simple Rule to add a v4 standard UUID to a user’s app_metadata:

1 Like

Thanks a lot @markd for sharing that!

How can i make sure that everytime this uuid will be unique over the system.

That’s more difficult, but it is worth mentioning that the likelihood of collisions is vanishingly small.

You could have the rule search all your user profiles before adding the UUID, but that runs the risk of stalling the authentication flow.

A better option would be to use version 5 namespace-based UUIDs, but last time I checked that wasn’t an available in an Auth0 Rule.

https://github.com/auth0-extensions/canirequire/issues/39

Thanks. I got another solution. What i am doing now is, when a new user gets register i simply get the system date time upto milli seconds, convert into time stamp and put in user profile as a unique ID.

1 Like

Thanks for sharing it with the rest of community!

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