Hello, Its possible to add UserId to token? I want to send data to API but I don’t want send userId in body. On every rest token should be regenareted with new UserId. I read about hooks and rules, but I think it wont work in this case
Hi @amek-96,
Welcome to the Auth0 Community!
You can find the user ID created by Auth0 in the token as the sub
claim. For example:
{
"iss": "http://YOUR_DOMAIN/",
"sub": "auth0|123456", //This is the user's ID
"aud": "YOUR_CLIENT_ID",
"exp": 1311281970,
"iat": 1311280970,
"name": "Jane Doe",
"given_name": "Jane",
"family_name": "Doe",
"gender": "female",
"birthdate": "0000-10-31",
"email": "janedoe@example.com",
"picture": "http://example.com/janedoe/me.jpg"
}
Otherwise, you can add any claim you would like to the token by using custom claims in an action. Here is an example where the action adds a role to the token. You can easily swap this for an ID:
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.