# Add Custom Claims to User Profile (User / App Metadata)

**URL:** <https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428>\
**Category:** Get Help\
**Tags:** jwt, rules, auth0\
**Created:** [March 15, 2020, 10:41am UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428 "2020-03-15T10:41:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johncat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johncat/32/12826_2.png) [@johncat](https://community.auth0.com/u/johncat)\
**Post date:** [March 15, 2020, 10:41am UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428/1 "2020-03-15T10:41:16Z")

</div>

I want to send the client some additional info in the user profile. I created the following rule:

> function (user, context, callback) {  
> user.app\_metadata = user.app\_metadata || {};  
> user.app\_metadata.test = “some value”;
> 
> ```
> auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
> .then(function() {
> let namespace = 'https://mysite.com/';
> context.idToken[namespace + 'app_metadata'] = user.app_metadata;
> callback(null, user, context);
> })
> .catch(function(err) {
> callback(err);
> });
> 
> ```
> 
> }

However, instead of receiving this (which I expected):

```
{
  app_metadata: {
   test: "some value"
  }
  nickname: "afaafa11fdf"
  name: "afaafa11fdf@bob.com"
}

```

I receive this:

```
{
  https://mysite.com/app_metadata: {
    test: "some value" 
  }
  nickname: "afaafa11fdf"
  name: "afaafa11fdf@bob.com"
}

```

I have been following [these guidelines here](https://auth0.com/docs/api-auth/tutorials/adoption/scope-custom-claims?_ga=2.125653578.1314846914.1584112305-222595504.1582535442#custom-claims).

---

<div class="post-metadata">

**Author:** ![mathiasconradt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mathiasconradt/32/12758_2.png) [@mathiasconradt](https://community.auth0.com/u/mathiasconradt)\
**Post date:** [March 15, 2020, 1:01pm UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428/2 "2020-03-15T13:01:20Z")

</div>

That’s all as expected and also as described in the documentation, which states:

> Note that the `user_id` property is sent as `sub` in the ID Token, and that `favorite_color` and `user_metadata` are not present in the OIDC response from Auth0. This is because OIDC does not define standard claims to represent all the information in this user’s profile. We can, however, define a non-standard claim by namespacing it through a [rule](https://auth0.com/docs/rules):

Since `app_metadata` and `user_metadata` isn’t a standard OIDC claim, it needs to go into a custom claim, which is always returned with the whole namespace / namespace URL.

> However, instead of receiving this (which I expected):

This is just how it’s stored on Auth0 user store end, but not as it’s returned in the ID token. Just as the docs state: _“This would be the profile stored by Auth0: […]”_ - that’s not the same format as what is returned in the ID Token.

---

<div class="post-metadata">

**Author:** ![johncat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/johncat/32/12826_2.png) [@johncat](https://community.auth0.com/u/johncat)\
**Post date:** [March 16, 2020, 12:07pm UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428/3 "2020-03-16T12:07:44Z")

</div>

Alright thank you, I misunderstood this then!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 16, 2020, 12:15pm UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428/4 "2020-03-16T12:15:35Z")

</div>

Glad you understand it now. Thanks @mathiasconradt for providing the clarification!

---

<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:** [March 31, 2020, 12:15pm UTC](https://community.auth0.com/t/add-custom-claims-to-user-profile-user-app-metadata/39428/5 "2020-03-31T12:15:37Z")

</div>

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