Reading roles inside a rule

Hey guys;

My goal is to assign an initial role to a user on first login. I want to find the appropriate role’s id so I want to fetch the list of all roles and then get the id of the target role for assignment to the user.

I’m getting the following error when I try to call getRoles:
Unhandled rejection APIError: {"statusCode":403,"error":"Forbidden","message":"Insufficient scope, expected any of: read:roles","errorCode":"insufficient_scope"}

  var ManagementClient = require('auth0@2.17.0').ManagementClient;
  var management = new ManagementClient({
    token: auth0.accessToken,
    domain: auth0.domain

      management.getRoles().then(function (roles) {
        console.log('roles', roles);

Any pointers appreciated :slight_smile:

Hi @ryantomaselli,

You will need to get an access token using a client credentials grant if you want to access any scopes other than read:users or update:users.

As mentioned at the bottom of this doc.

Let me know if you need more help with this.



Regarding this part of the question, and in addition to Dan’s reply, there was a similar post just last week:

1 Like

Also, this FAQ could be helpful.

1 Like

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