Add List user's organizations id and roles to the token

Hello!
I’m trying to create a rule or something to add the list user’s organizations and it’s roles to the token…:
for example the token would be something like this:

{
“roles”: [
“REGULAR”,
“SUPERADMIN”
],
“iss”: “https://example.eu.auth0.com/”,
“sub”: “auth0|000123123000”,
“aud”: [
https://example//api/v1/”,
https://example.eu.auth0.com/userinfo
],
“iat”: 1653295571,
“exp”: 1653303631,
“azp”: “cp2hivXUCzelTGKp4WQymFibf39GZs3O”,
"organizations: [{org1Id: 12345, roles:[“Regular-User, Admin”]}, {org2Id: 131231241, roles:["READER, SUPER ADMIN]}…]

}

I hope you can help me!!

Hello there @agustin.soler !

Assuming a user is authorizing through an organization, the org_id should be present in the ID/Access token(s) returned - Please see this article for more details.

Regarding roles specifically, we recommend setting up an Action to add these as a custom claim to tokens:

Hope this helps!

Hello @tyf thank you !

But with a “regular login” is there a way to get the list of all organizations that the user belongs and add it to the token like I askeb above?

"organizations: [{org1Id: 12345, roles:[“Regular-User, Admin”]}, {org2Id: 131231241, roles:["READER, SUPER ADMIN]}…]

1 Like

Happy to help where I can!

Without logging in within the context of an organization, I’m not aware of a way to add the Organizations to a user’s id/access token - You could always poll the Management API for a list of Organizations the user is associated with, but again this would be outside the scope of a token.

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