Adding user via dashboard does not set preferred_username

Hi,

In a new tenant, I have configured an Username-Password-Authentication connection with “Requires Username” and “Disable Sign Ups” set. I have an application configured with “OIDC Conformant” set.

When I manually add a user through the dashboard and configure their username this appears in the raw JSON view as username. When I get user profile details via getUser or getIdTokenClaims from the auth0-spa-js SDK I am expecting to see the OIDC preferred_username field supplied as part of the standard claim set. I do not. I don’t see either username or preferred_username.

Any assistance much appreciated!

Simon

I must have asked something either dumb or truly exotic! Almost every question bar mine someone has managed to weigh in on with a response. Hope someone can provide some pointers!

It seems like prefered_username claim is not present in the token. As a workaround, you can try using Rule to map the username property to prefered_username claim.

function (user, context, callback) {

  user.preferred_username = user.username;
  return callback(null, user, context);
}
2 Likes

This worked a treat, thanks. As the preferred_username claim is part of the standard OIDC set there’s no need to request it specifically in the scope - which is nice.

As a feature request, I’d suggest considering adding this mapping automatically. I can’t think of any strong reasons why this shouldn’t be the case for people opting in to OIDC compliant flows.

1 Like

Great to hear that! We’ll file that as a feature request to our product team.

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