removeRolesFromUser using Managment Client not working

// permissions set to add and remove roles
//adding works. Removing it doesnt

var ManagementClient = require('auth0').ManagementClient;

let roles = {
    'nm3sys-subscriber': 'rol_VSesH1Wg4joH57yD'
}

//works
management.assignRolestoUser({ id: 'google-oauth2|1049831542343243244176' }, { roles: [roles['nm3sys-subscriber']] }, function (err, roles) {
    if (err) {
        console.log(err);
    }
    console.log(roles);
});

//does not work
 management.removeRolesFromUser({ id: 'google-oauth2|1049831542343243244176' }, { roles: ['nm3sys-subscriber'] }, function (err, roles) {
    if (err) {
        console.log(err);
    }
    management.getUserRoles({ id: 'google-oauth2|104983158231490614176' }, function (err, roles) {
        if (err) {
        console.log(err);
        }
        console.log( {roles:roles});
    });

Hi @questsin,

Welcome to the Auth0 Community!

After looking carefully at your removeRolesFromUser request, I noticed that you were not referencing your role_id.

Could you please try the following instead and let me know how it goes:

 management.removeRolesFromUser({ id: 'google-oauth2|1049831542343243244176' }, { roles: [roles['nm3sys-subscriber']] }, function (err, roles) {
    if (err) {
        console.log(err);
    }
 ...

Thanks,
Rueben

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