How to assign custom ids on account creation with social logins?

We are assigning a unique company id to users that register on our Auth0 and then put that id into access tokens that those users will then use to access our APIs.

The action flow is simple:

  1. Pre-registration: Auth0 calls an endpoint on our infrastructure which creates a new user in our database and returns the company id to Auth0. The action will store that company id as user_metadata.
  2. Login: The login flow will read the company from user_metadata and add it as custom claim to our access tokens.

Works pretty well and we have that company id available on the first login. However, as the pre-registration action flow doesn’t work with social logins, how can we implement that functionality there?

Hi @eosn-fred,

You could use a post-login action instead of a pre-reg action. You can make the same endpoint call and metadata update whenever event.stats.logins_count = 1 OR if the user doesn’t have a company id property.

Also, you may want to use app metadata instead of user metadata.

1 Like

Yes, makes sense to use the app_metadata here. Thanks for the tip!

1 Like

Great! Let me know if you have any other questions!

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