Hello,
I am having problems getting the roles of a user.
I have created the roles and associated users with them. Two Roles Admin and User and two users one for each role.
I also have created in the Login flow the code to get the roles:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://dev-1flzkotdey2fm74y.us.auth0.com';
if (event.authorization) {
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
}
};
I request the getAccessTokenSilently and the accessToken is received with the payload but the roles are not coming:
{
"iss": "https://dev-1flzkotdey2fm74y.us.auth0.com/",
"sub": "auth0|642335d4e1118da83ff192a5",
"aud": [
"https://dev-1flzkotdey2fm74y.us.auth0.com/api/v2/",
"https://dev-1flzkotdey2fm74y.us.auth0.com/userinfo"
],
"iat": 1681297803,
"exp": 1681384203,
"azp": "OairsgbVMfSz5GNl6k0QuWXq4kmcmqPQ",
"scope": "openid profile email"
}
What am I missing?
Best regards,