I’m trying to follow ChatGPT’s advice on how to get my custom roles listed in the JWT claims.
I’ve added this to my login flow
exports.onExecutePostLogin = async (event, api) => {
const namespace = ‘https://dualitysocial.us.auth0.com/’;// Check if the user has roles in app_metadata or user_metadata
let roles = ;
if (event.user.app_metadata && event.user.app_metadata.roles) {
roles = event.user.app_metadata.roles;
} else if (event.user.user_metadata && event.user.user_metadata.roles) {
roles = event.user.user_metadata.roles;
}
console.log(event.user.app_metadata.roles);
console.log(event.user.user_metadata.roles);
console.log(roles);// Append roles to the ID and/or Access Token
api.idToken.setCustomClaim(namespace + ‘roles’, roles);
api.accessToken.setCustomClaim(namespace + ‘roles’, roles);
};
But I can’t find where to enable RBAC- ChatGPT says it is under the API somewhere, but I can’t find it anywhere, and the user metadata is empty.