# App\_metadata not included in IdToken or accessToken

**URL:** <https://community.auth0.com/t/app-metadata-not-included-in-idtoken-or-accesstoken/80889>\
**Category:** Get Help\
**Tags:** jwt, auth0, login\
**Created:** [March 31, 2022, 11:06am UTC](https://community.auth0.com/t/app-metadata-not-included-in-idtoken-or-accesstoken/80889 "2022-03-31T11:06:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmarzouk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hmarzouk/32/36289_2.png) [@hmarzouk](https://community.auth0.com/u/hmarzouk)\
**Post date:** [March 31, 2022, 11:06am UTC](https://community.auth0.com/t/app-metadata-not-included-in-idtoken-or-accesstoken/80889/1 "2022-03-31T11:06:38Z")

</div>

We’re adding custom information to user profile to handle a multi-tenant API:  
app\_metadata ==\>

```auto
{
  "tenants": [
    "cad93b22-0838-4037-9f2c-16d80f0444f1"
  ]
}

```

We need to get back this information in the AccessToken throw the password credentials flow.  
Here our request:

```auto
curl --location --request POST 'https://xxxxxxxxxx.eu.auth0.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=xxxxxxxxxxx' \
--data-urlencode 'password=xxxxxxx' \
--data-urlencode 'audience=https://localhost:5000' \
--data-urlencode 'client_id=xxxxxxxxxx' \
--data-urlencode 'client_secret=xxxxxx' \

```

We added a custom action. Here the code:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://data-grapes.com';
  api.idToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
};

```

We’ve also added the custom action in the Login flow.

Unfortunately, the app\_metadata is still not present in the AccessToken.

Any help is apreciated.

Regards

---

<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:** [April 15, 2022, 5:57am UTC](https://community.auth0.com/t/app-metadata-not-included-in-idtoken-or-accesstoken/80889/3 "2022-04-15T05:57:00Z")

</div>

Hi there @hmarzouk welcome to the community!

> [@hmarzouk](#):
>
> Unfortunately, the app\_metadata is still not present in the AccessToken.

According to the Action code you’ve shared, the `app_metadata` is set to be added to the user ID Token - However, the [Resource Owner Password flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow) will only return an Access Token. Are you able to confirm whether or not the `app_metadata` is returned in the Access Token if you update your Action to the following?

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://data-grapes.com';
  api.accessToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
};

```

Let us know!

---

<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:** [April 30, 2022, 5:57am UTC](https://community.auth0.com/t/app-metadata-not-included-in-idtoken-or-accesstoken/80889/4 "2022-04-30T05:57:31Z")

</div>

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