# How to get user ID, cant do it with sub

**URL:** <https://community.auth0.com/t/how-to-get-user-id-cant-do-it-with-sub/123629>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [December 24, 2023, 10:43am UTC](https://community.auth0.com/t/how-to-get-user-id-cant-do-it-with-sub/123629 "2023-12-24T10:43:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zedeleyici](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zedeleyici/32/49217_2.png) [@zedeleyici](https://community.auth0.com/u/zedeleyici)\
**Post date:** [December 24, 2023, 10:43am UTC](https://community.auth0.com/t/how-to-get-user-id-cant-do-it-with-sub/123629/1 "2023-12-24T10:43:55Z")

</div>

Hello everyone,

For the operations I want, I need user ID. For example, view roles consists of a line as

```auto
conn.request("GET", "/{yourDomain}/api/v2/users/USER_ID/roles", headers=headers)

```

Stated by Auth0. Therefore, I need to access it. Now I can access nickname, email, name and similars with

```auto
id_token = token.get('id_token')
jwk_set = oauth.auth0.fetch_jwk_set()
user_info = jwt.decode(id_token, jwk_set)
print("------------------------")
print(user_info)
print("------------------------")

```

However, it does not consists of user ID. The id\_token variable above is something like

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik55VnVhbjR3OTdoZG1NdkVOdGMyaCJ9.eyJuaWNrbmFtZSI6Im9hdGFzb3kxOSIsIm5hbWUiOiJvYXRhc295MTlAa3UuZWR1LnRyIiwicGljdHVyZSI6Imh0dHBzOi8vcy5ncmF2YXRhci5jb20vYXZhdGFyL2FhNWE3YzJjMWRiZDk2NjBmZWJlNzA5OTQzMWQzZTZjP3M9NDgwJnI9cGcmZD1odHRwcyUzQSUyRiUyRmNkbi5hdXRoMC5jb20lMkZhdmF0YXJzJTJGb2EucG5nIiwidXBkYXRlZF9hdCI6IjIwMjMtMTItMjRUMTA6NDI6NTguNDUzWiIsImVtYWlsIjoib2F0YXNveTE5QGt1LmVkdS50ciIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJpc3MiOiJodHRwczovL2NhZ2VkYS5ldS5hdXRoMC5jb20vIiwiYXVkIjoiNmthNElncGZXSDVqQmxmMHFDV1lTOVl3cmFFbGZzOU0iLCJpYXQiOjE3MDM0MTQ1ODAsImV4cCI6MTcwMzQ1MDU4MCwic3ViIjoiYXV0aDB8NjU2OGUxNTEwMzAwOTY2YWQzYjdkMTA2Iiwic2lkIjoiRlBSdzJlbmZ0MzVzYTlqb1pSdUszbWhlQkd4dVRwbHUiLCJub25jZSI6Inh0WlpFWGhYQ05KNnZhUnI0N1l6In0.SfI-4ObKcSS4dg3HE3dpe-yzGjbtc0YbSBgSuGGO-\_FJT3XUJP–I49QYocjWDsi6ITk0Z7bx8MED19-k3CgTOuZiqMbiJsevHat7mozEsOmKlbC0TbQTSQdtsIOhD-rRYAqHSFzEsulC5zeLqV6SHUIm\_GoRKXskVrolMj7lrWXldUe9gt-c9q–3c3GflcE10K2IL3DbP\_kH\_wFZ1kfUL456o9zESYXYu8BXc9oJ9IoNjJ3X1EsV6YFf7Pb5QR8FedqhIKQ62sScHciEAov43jc2oZLuev77Hj1GibSHz6mb6EwyNCLlW9jFeo-eMsX9EKxWgE2a1VGFIXuf5sXw

Which I quite feel unfamiliar.

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [December 25, 2023, 10:36pm UTC](https://community.auth0.com/t/how-to-get-user-id-cant-do-it-with-sub/123629/2 "2023-12-25T22:36:38Z")

</div>

Hi @zedeleyici

Thanks for contacting the Auth0 Community.

The id\_token variable that you pasted is the JWT (json web token). If you paste this into [https://jwt.io/](https://jwt.io/) you’ll see the sub value which will be the user\_id. Please review [https://auth0.com/docs/secure/tokens/json-web-tokens/validate-json-web-tokens](https://auth0.com/docs/secure/tokens/json-web-tokens/validate-json-web-tokens) the recommended approach is to use verify() as opposed to decode(). You should be able to extract the sub value and use this in the endpoint that you mentioned.

Warm regards

---

<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:** [January 8, 2024, 10:37pm UTC](https://community.auth0.com/t/how-to-get-user-id-cant-do-it-with-sub/123629/3 "2024-01-08T22:37:35Z")

</div>

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