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

**URL:** <https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512>\
**Category:** Get Help\
**Created:** [July 21, 2021, 8:16am UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512 "2021-07-21T08:16:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eosn-fred](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eosn-fred/32/12732_2.png) [@eosn-fred](https://community.auth0.com/u/eosn-fred)\
**Post date:** [July 21, 2021, 8:16am UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512/1 "2021-07-21T08:16:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 21, 2021, 5:26pm UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512/3 "2021-07-21T17:26:24Z")

</div>

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](https://auth0.com/docs/users/metadata).

---

<div class="post-metadata">

**Author:** ![eosn-fred](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eosn-fred/32/12732_2.png) [@eosn-fred](https://community.auth0.com/u/eosn-fred)\
**Post date:** [July 22, 2021, 8:21am UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512/4 "2021-07-22T08:21:56Z")

</div>

Yes, makes sense to use the app\_metadata here. Thanks for the tip!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 22, 2021, 3:41pm UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512/5 "2021-07-22T15:41:09Z")

</div>

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

---

<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:** [August 6, 2021, 3:41pm UTC](https://community.auth0.com/t/how-to-assign-custom-ids-on-account-creation-with-social-logins/66512/6 "2021-08-06T15:41:49Z")

</div>

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