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));
});