Auth0 Home Blog Docs

Setting username



I am creating a login form using Auth0 Lock. In the Auth0 dashboard, I made it so it required a username as well. However, this is getting stored into the profile.nickname. I am trying to make it so that users can edit their profile information, but as of right now Auth0 does not allow you to update the nickname field with the api. However, it allows you to edit the username field which I’m assuming should be able to retrieve this. How do I access this username field? My scopes are profile, email, openid, and user_metadata, but none of these return the username attribute.

My other option is to not use the username field, and to create an additionalSignUp field for users to put in a username. This way I can edit it since it’ll be stored into user_metadata instead. However, how do I make these usernames unique? How do I make it so the entry to an additionalSignUpField is unique?


Hi @gordonlimusic,

Although I could not understand the problem very well,
Just in case you can find some help![here][1]

You can make the username field mandatory for database connection by enabling the required username flag, from your dashboard. This would make the username field visible on the Auth0 hoisted login and signup forms. Also, you can access the username via username field just like the emailAddress.


I did that but when the user signs up with a username after I set the “Requires Username”, it adds that to the user.nickname attribute which I cannot update. I am trying to allow to user the update their username, but because Auth0 update API does not support updating their nickname, I cannot.


Hi @gordonlimusic

After exploring a little more, I think you drew this perception by the looking at the id_token in which the username is stored in the nickname field.

But when I tried updating the username using the management API, I was able to do that successfully. Please follow this doc for more information and revert back in case of any concerns.


Thank you!
Is there a way I can return the username using the getUserInfo function that auth0 provides? My scopes currently are profile, email, openid, and user_metadata. My current response does not give me the username back.


Hi @gordonlimusic,

Sorry for the late reply!
In my opinion, perhaps the nickname field in the id_token(received as a response through this call) corresponds to the username if it exists for the user.

This discussion might help you resolve your use case.

Additionally, you can also get a user’s details via the management API call to get a user.