# Get username with auth0 react sdk

**URL:** <https://community.auth0.com/t/get-username-with-auth0-react-sdk/47514>\
**Category:** Get Help\
**Tags:** auth0-rules\
**Created:** [August 5, 2020, 8:26pm UTC](https://community.auth0.com/t/get-username-with-auth0-react-sdk/47514 "2020-08-05T20:26:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmwill934](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gmwill934/32/22277_2.png) [@gmwill934](https://community.auth0.com/u/gmwill934)\
**Post date:** [August 5, 2020, 8:26pm UTC](https://community.auth0.com/t/get-username-with-auth0-react-sdk/47514/1 "2020-08-05T20:26:08Z")

</div>

So I am trying to get the username from my user object thats retried with the `useAuth0` hook.

```
function (user, context, callback) {
context.idToken['username'] = user.username;
  return callback(null, user, context);
}

```

That is the rule I am creating on auth0, but I get an error.

 ![Screen Shot 2020-08-05 at 15.24.39](https://global.discourse-cdn.com/auth0/original/3X/6/9/699d3561454650c871bad7c81f3c02d9ff02c743.png)

How should I then name the `property`?

I want to access it on the front end to display it on my profile page.

Thanks

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [August 6, 2020, 8:12am UTC](https://community.auth0.com/t/get-username-with-auth0-react-sdk/47514/2 "2020-08-06T08:12:34Z")

</div>

Hey @gmwill934, Welcome to the Auth0 Community!

The custom claim you add into your ID token has to be name spaced.  
Please find more information and example below:

> **[OpenID Connect Scopes](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes)**
>
> Understand scopes and claims used with the OpenID Connect (OIDC) protocol.

If you add something like below should work :  
const namespace = ‘[https://myapp.example.com/](https://myapp.example.com/)’;  
context.idToken[namespace +‘username’] = user.username;

Let me know how you go!

Regards,  
Sidharth Chaudhary

---

<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:** [August 21, 2020, 8:26am UTC](https://community.auth0.com/t/get-username-with-auth0-react-sdk/47514/3 "2020-08-21T08:26:49Z")

</div>

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