# Get user id on login

**URL:** <https://community.auth0.com/t/get-user-id-on-login/80152>\
**Category:** Get Help\
**Created:** [March 18, 2022, 11:26pm UTC](https://community.auth0.com/t/get-user-id-on-login/80152 "2022-03-18T23:26:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jezerro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jezerro/32/36004_2.png) [@jezerro](https://community.auth0.com/u/jezerro)\
**Post date:** [March 18, 2022, 11:26pm UTC](https://community.auth0.com/t/get-user-id-on-login/80152/1 "2022-03-18T23:26:45Z")

</div>

Hello, im new to this service. i followed the tutorial to implement a basic login/register popup and it works fine, but i need to get the users unique id, is it possible? I need it to get each users data from the db

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 19, 2022, 12:01am UTC](https://community.auth0.com/t/get-user-id-on-login/80152/3 "2022-03-19T00:01:50Z")

</div>

Hey there @jezerro welcome to the community!

Are you just looking for the user’s ID as it is in Auth0? If that’s the case I recommend looking into [Actions](https://auth0.com/docs/customize/actions/actions-overview) and in particular a [Post Login Action](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow) wherein you can access the `user_id` with `event.user.user_id` as outlined [here](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object).

Let us know!

---

<div class="post-metadata">

**Author:** ![jezerro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jezerro/32/36004_2.png) [@jezerro](https://community.auth0.com/u/jezerro)\
**Post date:** [March 19, 2022, 3:20am UTC](https://community.auth0.com/t/get-user-id-on-login/80152/4 "2022-03-19T03:20:58Z")

</div>

hey tyf, thanks for the quick reply! user\_id is indeed what i need, but im not sure how i send it to the client. i created an action with a onExecutePostLogin() handler that just returns it, is that the correct way? Also, is there a specific handler on the client side i must use? Thanks!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 21, 2022, 11:52pm UTC](https://community.auth0.com/t/get-user-id-on-login/80152/5 "2022-03-21T23:52:20Z")

</div>

No problem, happy to help where I can!

How exactly are you logging users in? Are you using an OAuth/OIDC flow via an Auth0 SDK? The _user\_id_ is available as the `sub` claim in an ID Token if you are indeed using a flow that results in one. Alternatively, you could get the `sub` claim from the [/userinfo endpoint](https://auth0.com/docs/api/authentication#get-user-info) using the user’s access token. This can all be done outside of an action entirely which might be a more straightforward approach.

From within an action, you might want to look at using an external library such as [axios](https://www.npmjs.com/package/axios) (or any publicly available npm package) to communicate with your service.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 5, 2022, 11:52pm UTC](https://community.auth0.com/t/get-user-id-on-login/80152/6 "2022-04-05T23:52:21Z")

</div>

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