I have a nodejs express service with express-jwt with a protected api call.
app.get('/protected',
jwtCheck, function(req, res) {
console.log(JSON.stringify(req.user));
if (!req.user.admin)
return res.send("user");
res.send("admin");
});
The problem is, the req.user object does not contain the "admin" field. I have added the roles in Auth0 rules, so I can get it to work in my client, just not in the nodejs server.
I followed the tutorial from here: https://github.com/auth0/express-jwt
Have I missed something here? Is there a rule I need to set in auth0 so the admin field is added?
EDIT: Found this description in a git issue: "Your token needs to contain the information (eg: roles). In order to do so with Auth0, you have to request the appropriate scope, eg: scope=openid email roles." Now, how do I edit the scope for express-jwt?
Thanks in advance!