Auth0 Home Blog Docs

Users.get does not return individual user for management call with Node.js

nodejs

#1

Hi, I am using the node module provided to return the username for an individual user.

const auth0 = new ManagementClient({
  domain: config.AUTH0_DOMAIN,
  clientId: config.AUTH0_CLIENT_ID,
  clientSecret: config.AUTH0_CLIENT_SECRET,
  scope: 'read:users update:users read:user_idp_tokens'
});

app.get(’/api/user/name/:id’, jwtCheck,(req, res) => {
auth0.users.get(req.params.id,function (err, users) {
if (err) {
return res.status(500).send({message: err.message});
}
console.log(users);
console.log(req.params.id)
const userName = JSON.stringify(users[0].name);
res.send(userName);
});
});

The result returned gives me all users (so access the mgnt api works), but not the user identified by facebook|nnnnnnnnnnn which is confirmed in the console output

Any ideas why this is?


#2

According to docs, this is the right way to use this method:

http://auth0.github.io/node-auth0/module-management.UsersManager.html#get

auth0.users.get({id: req.params.id}, function(err, user) {
  res.send(user.name)
});