Having trouble getting roles from claims

I am working on a Node project and I am having issues getting the roles from the claims. I see the roles assigned to the user in the Authorization extension. I have the following code to check it…

    oidc.claimCheck((claims) => {
        console.log(`The roles are ${JSON.stringify(claims.roles)}`)
        return claims.isAdmin || ( claims.roles && claims.roles.includes('editor'));
    (req, res)=>{
        // TODO: Add a new post
        res.send("Claim worked");

But I get…

The roles are undefined

What am I missing?

Hi @jackiegleason,

It may help to decode the entire ID Token at https://jwt.io/ to see the entire token.

Custom claims are namespaced, so if you are following the example in the docs, then the roles may be stored in claims['https://your_app.com/roles'] instead of claims.roles

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