# How can get the name of the user in JWT token?

**URL:** <https://community.auth0.com/t/how-can-get-the-name-of-the-user-in-jwt-token/119288>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [October 24, 2023, 4:00pm UTC](https://community.auth0.com/t/how-can-get-the-name-of-the-user-in-jwt-token/119288 "2023-10-24T16:00:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oleh.naumenko](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oleh.naumenko/32/51919_2.png) [@oleh.naumenko](https://community.auth0.com/u/oleh.naumenko)\
**Post date:** [October 24, 2023, 4:00pm UTC](https://community.auth0.com/t/how-can-get-the-name-of-the-user-in-jwt-token/119288/1 "2023-10-24T16:00:42Z")

</div>

Using Auth0 Swift API:  
When signing up using email + password, I include “name” field in user metadata.  
When logging in I receive JWT token that has “name” field and it is always populated with user’s email. I want it to be populated with actual user’s name. How Do I let Auth0 know user’s name during registration and reflect it when logging in?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [October 24, 2023, 10:35pm UTC](https://community.auth0.com/t/how-can-get-the-name-of-the-user-in-jwt-token/119288/3 "2023-10-24T22:35:42Z")

</div>

Hey there @oleh.naumenko welcome to the community!

Just to confirm, you are setting a `name` property in a user’s [user\_metadata](https://auth0.com/docs/manage-users/user-accounts/metadata#metadata-types) currently? If that’s the case, you can use an [Action](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow) to override the `name` claim in ID and/or access tokens using something like the following code:

```auto
exports.onExecutePostLogin = async (event, api) => {

 // Check if the user_metadata has the "name" key
  if (event.user.user_metadata && event.user.user_metadata.name) {
    // Set a custom claim in the ID Token
    api.idToken.setCustomClaim('name', event.user.user_metadata.name);
    // Set a custom claim in the Access Token
    api.accessToken.setCustomClaim('name', event.user.user_metadata.name);
  }
};

```

---

<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:** [November 7, 2023, 10:36pm UTC](https://community.auth0.com/t/how-can-get-the-name-of-the-user-in-jwt-token/119288/5 "2023-11-07T22:36:26Z")

</div>

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