Hi, i’m using
@auth0 /nextjs-auth0@^1.9.2
I added some roles and permission to the user but i cannot see those on user profile.
I get a JSON like this:
{
"given_name": "XXX",
"family_name": "XXX",
"nickname": "XXXX",
"name": "TEST",
"picture": "https://lh3.googleusercontent.com/a/ALm5wu00F67aDunHRV9EdLjKN94LbOYW7E9LbPFWCtOE=s96-c",
"locale": "it",
"updated_at": "2022-10-10T06:56:02.203Z",
"email": "xxxxxxxxx@gmail.com",
"email_verified": true,
"sub": "google-oauth2|10015xxxxxxxx23",
"sid": "Yoxxxc-_-txxxxxxx7L"
}
How i can add those fields to the user i’m getting on the frontend?
tyf
October 12, 2022, 12:17am
3
hey @barekliton welcome to the community!
You’ll need to explicitly add the roles to ID Tokens using an Action as outlined in the following FAQ:
Problem statement
Is it possible to retrieve the user’s Roles and/or Permissions and include them in the JWT Token?
Solution
Yes, it’s possible to retrieve the user’s Roles and/or Permissions and append them to either the ID Token or Access Token. To do so, you must use a Post-Login Action script.
1.1 Roles
When adding the user’s Roles to the token, call the event.authorization.roles property and add it as a custom claim to the Token. Please see here on creating namespaced custom claims. Be…
Permissions are a bit different, and are typically kept within the context of an access token. I recommend taking a look at RBAC as this provides you with the option (assuming you have an API registered in Auth0) to automatically add permissions to user’s access tokens.
Hope this helps!
1 Like
system
Closed
October 26, 2022, 12:18am
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.