# I cannot get the Username field from the database

**URL:** <https://community.auth0.com/t/i-cannot-get-the-username-field-from-the-database/68855>\
**Category:** Get Help\
**Created:** [August 31, 2021, 1:00pm UTC](https://community.auth0.com/t/i-cannot-get-the-username-field-from-the-database/68855 "2021-08-31T13:00:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fidel.torres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fidel.torres/32/13740_2.png) [@fidel.torres](https://community.auth0.com/u/fidel.torres)\
**Post date:** [August 31, 2021, 1:00pm UTC](https://community.auth0.com/t/i-cannot-get-the-username-field-from-the-database/68855/1 "2021-08-31T13:00:34Z")

</div>

When users register, even though they type the username, I can’t get it from the app, could you tell me how I get this information?

---

<div class="post-metadata">

**Author:** ![sgo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sgo/32/13789_2.png) [@sgo](https://community.auth0.com/u/sgo)\
**Post date:** [August 31, 2021, 3:13pm UTC](https://community.auth0.com/t/i-cannot-get-the-username-field-from-the-database/68855/2 "2021-08-31T15:13:42Z")

</div>

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](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims), 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:

```auto
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:

- Actions method: [Login Flow](https://auth0.com/docs/actions/triggers/post-login#add-user-roles-to-tokens)
- Rules method: [Sample Use Cases: Scopes and Claims](https://auth0.com/docs/configure/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token)
- [Create Custom Claims](https://auth0.com/docs/security/tokens/json-web-tokens/create-namespaced-custom-claims)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 15, 2021, 3:14pm UTC](https://community.auth0.com/t/i-cannot-get-the-username-field-from-the-database/68855/3 "2021-09-15T15:14:40Z")

</div>

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