# Management client api not working for roles and permission in Rules

**URL:** <https://community.auth0.com/t/management-client-api-not-working-for-roles-and-permission-in-rules/63711>\
**Category:** Get Help\
**Created:** [June 2, 2021, 6:48am UTC](https://community.auth0.com/t/management-client-api-not-working-for-roles-and-permission-in-rules/63711 "2021-06-02T06:48:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail4mithu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mail4mithu/32/12776_2.png) [@mail4mithu](https://community.auth0.com/u/mail4mithu)\
**Post date:** [June 2, 2021, 6:48am UTC](https://community.auth0.com/t/management-client-api-not-working-for-roles-and-permission-in-rules/63711/1 "2021-06-02T06:48:22Z")

</div>

Hello,

We are trying to read permission based on role id in Rules, we are using ( node-auth0 reference link below)  
[https://auth0.github.io/node-auth0/module-management.ManagementClient.html#getPermissionsInRole](https://auth0.github.io/node-auth0/module-management.ManagementClient.html#getPermissionsInRole)  
but its working only for getUser and not for any other management API. could some one help me to solve this issue.

const ManagementClient = require(‘auth0@2.35.0’).ManagementClient;  
const management = new ManagementClient({  
token: auth0.accessToken,  
domain: auth0.domain  
});

const roleId = {id: ‘role\_id’};  
const getPermission = await management.getPermissionsInRole(roleId);  
console.log(“getPermission”, getPermission);

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 2, 2021, 12:25pm UTC](https://community.auth0.com/t/management-client-api-not-working-for-roles-and-permission-in-rules/63711/3 "2021-06-02T12:25:23Z")

</div>

Hi @mail4mithu,

`getPermissionsInRole` requires the permission `read:roles` ([Auth0 Management API v2](https://auth0.com/docs/api/management/v2#!/Roles/get_role_permission)). However, the Access Token for the Management API, which is available through `auth0.accessToken`, is limited to the `read:users` and `update:users` scopes ([Use the Management API from within Rules](https://auth0.com/docs/rules/use-management-api)).

To call `getPermissionsInRoles`, you can [register a Machine-to-Machine app](https://auth0.com/docs/tokens/management-api-access-tokens/create-and-authorize-a-machine-to-machine-application) with the `read:roles` permission for your rule and use the client credentials grant to get an Access Token:

```auto
const ManagementClient = require(‘auth0@2.35.0’).ManagementClient;
const management = new ManagementClient({
  domain: '{YOUR_ACCOUNT}.auth0.com',
  clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}', // <-- use the client ID of the m2m app you created for the rule
  clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}', // <-- use the client secret of the m2m app you created for the rule
  scope: "read:roles",
  audience: 'https://{YOUR_TENANT_NAME}.auth0.com/api/v2/'
})

const roleId = {id: ‘role_id’};
management.getPermissionsInRole(params, function (err, permissions) {
  if (err) {
    console.log(err);
  }
  console.log(permissions);
});

```

**Note:** You can also use an Action for this as well:

> **[Auth0 Actions](https://auth0.com/docs/customize/actions)**
>
> Describes Auth0 Actions, which are secure, tenant-specific, self-contained functions that allow you to customize the behavior of Auth0.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 17, 2021, 12:25pm UTC](https://community.auth0.com/t/management-client-api-not-working-for-roles-and-permission-in-rules/63711/4 "2021-06-17T12:25:34Z")

</div>

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