I cannot get the Username field from the database

Hi @fidel.torres , welcome to the community!

Do you mean in an ID token? As there isn’t a username claim in the standard spec, and Auth0 does not automatically map to the OIDC claim of preferred_username you would need to map the username via a rule, for example:

function (user, context, callback) {
  user.preferred_username = user.username; //map username to OIDC standard claim
  return callback(null, user, context);
}

This would allow you to return the username via the profile scope.

Alternatively, you could add it as a custom namespaced claim via a Rule or an Action:

2 Likes