Accessing role IDs in rules

I’m trying to write a rule that will assign a role to a user upon login. I’ve worked through several of the different examples & community posts, but I cannot find a way to access the role ID’s programmatically in the hook function.

The ManagementClient access tokens that are available in the rule do not have read:roles permissions, so I can’t use the getRoles() method. Alternatively, I’ve seen a post for finding the role ID manually (Assign Roles to users using Rules - #14 by dak2009), but in our situation, we’re launching tenants on-demand via terraform, so we won’t have the ability to manually track and update these IDs.

Are there workarounds that I’m missing?

Hi @auth0-admin1,

You should be able to register the hook as a M2M application and then request whatever scopes you want. This doc demonstrates how to do that:

Hope this helps,
Dan

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