Event.authorization.roles is an empty array

To help with authorise routes in UI, I want to add user roles to the user object and tokens.

Here’s the current setup:

  • Configured RBAC core
  • Ensured token_dialect value is correct
  • Created permissions on API
  • Created a role and assigned permissions to role
  • Assigned roles to users (using Authorisation Core)

Despite following these steps, the roles are not available in Actions or Rules. I’ve tried the following samples for Actions and Rules. Oddly, the test suite for Rules shows the correct roles on the user object :person_shrugging:.

Has anyone experienced similar issues?

1 Like

Hi @edc,

Thanks for reaching out to the Auth0 Community!

I understand that you have encountered a situation where the Roles assigned to users are not available in Actions or Rules.

After my investigation, I was able to successfully get the user’s assigned Roles using a Post-Login Action.

Moreover, the samples you followed for Actions and Rules is correct for appending the user’s assigned Roles to an ID Token.

In this case, could you please use the Real-time Webtask Logs Extension while testing your Post Login Action script to see if you can print the user’s assigned roles. For example:

exports.onExecutePostLogin = async (event, api) => {
  console.log("The assigned Roles are: ", event.authorization.roles);

I am looking forward to your update.

Thank you!

Thanks for sharing this tip on debugging - it helped me find where I had gone wrong. The roles array was initially empty in the logs:

7:14:38 PM:
 new webtask request
7:14:38 PM:
 The assigned Roles are: []
7:14:38 PM:
 finished webtask request

Previously, I had applied roles directly to users, and not within the context of an organization. When I applied a role to a user in an organization context (steps in the Management Dashboard: Organization > Select an org > Members > […] Assign Roles), the roles array was populated.

Thanks for the help, @rueben.tiow :raised_hands:


Hi @edc,

I’m glad you managed to solved the issue!

Please feel free to reach out again if you have any other questions.

Have a great rest of your day!