I have enabled usernames in my Database Connection, and the username field shows up for new user sign-ins. But after they sign in, when I try to access the username field using the user object from useAuth0(), I get undefined. There is a nickname field, but it isn’t set to the username either. How can I access the username that the user signed up with?
Hi,
Please verify where you have defined username field. Most probably it shold be in user_metada tag and you need to access it using user.user_metadata.username. In this way you will get your username.
Please let us know if it helps.
I am using createAuth0Client(initOptions).getUser()
to get the user object, as shown in the React tutorial: https://auth0.com/docs/quickstart/spa/react/01-login. I haven’t defined username anywhere myself, other than turning it on my my Database Connection.
If i am getting you correct you migrating users from third party database/system to auth0. Right?
No, I am not using a third-party db, I just want to use a user’s username in my frontend app and I’m unable to get it
Any update? I have the same issue. I am using useAuth0 hook in a React app to get user info. user object returned by useAuth0 has nickname field but not username. How can I get the username?
same issue here with React and useAuth(). Would really like further insight (tried using rules, does not seem to be the right thing here …)
I know you can probably use an API for this but it seems like something that should just be in the SDK judging by the docs.
same issue with angular. I’m currently evaluating Auth0 as a substitute to cognito. How are people using Auth0 if it doesn’t return usernames?
edit: I also switched using a 3rd party oidc client, still the same issue. I have all the scopes listed on my well-known endpoint on my client, but no “username” field is being returned
unsure what’s wrong with it, but I implemented a PostSignup action that overwrites the “username” field to “nickname” field with the auth0 management api to get around this issue.