Hi
I would like to add the users’ roles to the user objects I receive from this management api:
https://my-domain.us.auth0.com/api/v2/users
I’ve tried both actions and rules to add “roles” to id and access tokens via custom claims. They are added successfully to these tokens, but this has no effect on the user object I receive from the above API.
Is there a way to get roles as nested objects inside the user objects with a single request?
Hey there @stehranchi!
The roles will need to be added directly to the user in order to be included in the user object. You can still achieve this in Action, but you’ll need to use the Management API from within the Action itself, please see:
Hope this helps!
Thank you for your reply @tyf
Not sure that I’m understanding it correctly.
If I add the roles to the user’s meta-data in a post-login action, it means that after any changes in the user’s roles, these changes wont be applied to the user object, unless the user log into the system, am I right ?
Hey @stehranchi no problem, I’m happy to help!
Any change made to a user’s metadata (referring to metadata in this context) will be present in the user object/profile but it would require the user to re-authenticate in order to update any tokens accordingly.
I misspoke previously in saying that roles added via the Management API are available at /api/v2/users
- Any roles assigned directly to the user will need to be retrieved from /api/v2/users/{id}/roles
https://auth0.com/docs/api/management/v2#!/Users/get_user_roles
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.