Node ManagementClient getUserRoles is not a function

Hi there. I’m trying to get the roles assigned to a user by their id. When I call getUserRoles I get the error managementClient.getUserRoles is not a function. See below for my code. managementClient.getUser works fine. Any ideas?

function getAuth0ManagementClient() {
    const ManagementClient = require('auth0').ManagementClient;
    return new ManagementClient({
        domain: process.env.AUTH0_DOMAIN,
        clientId: process.env.AUTH0_CLIENT_ID,
        clientSecret: process.env.AUTH0_CLIENT_SECRET,
        scope: 'read:users update:users create:users read:roles'
    });
}
router.get('/', function(req, res, next) {
    const uid = req.uid;
    const managementClient = getAuth0ManagementClient();

    managementClient.getUserRoles({ id: uid })
        .then(roles => {
            res.json({ roles });
        })
        .catch(err => throwError(next, err));
});

I fixed the problem by updating from auth0 2.15.0 to 2.17.0

1 Like

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