Role based access configuration?

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 = ‘’;

// 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;

// 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.

Hi @JessicaMulein,

Welcome to the Auth0 Community!

You can enable this setting by going to your Auth0 Dashboard > Applications > API > Your API and scrolling to the RBAC Settings section to switch on the Enable RBAC toggle.


1 Like

Thank you. My problem was the default API doesn’t have this option but once I created a new one it was available.

1 Like

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