# User metadata as well as App metadata is not showing as part of acess token while using Action Library

**URL:** <https://community.auth0.com/t/user-metadata-as-well-as-app-metadata-is-not-showing-as-part-of-acess-token-while-using-action-library/133852>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [May 10, 2024, 1:14pm UTC](https://community.auth0.com/t/user-metadata-as-well-as-app-metadata-is-not-showing-as-part-of-acess-token-while-using-action-library/133852 "2024-05-10T13:14:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![selvi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/selvi/32/33945_2.png) [@selvi](https://community.auth0.com/u/selvi)\
**Post date:** [May 10, 2024, 1:14pm UTC](https://community.auth0.com/t/user-metadata-as-well-as-app-metadata-is-not-showing-as-part-of-acess-token-while-using-action-library/133852/1 "2024-05-10T13:14:45Z")

</div>

Hi,  
I tried to fetch user metadata as well as app metadata as part of access token Using Actions Library options. I tried in rules its working fine, but In case Of the Action it’s not working. Can anyone suggest the solution? Is there anything I need to enable it? Refer the sample code attached it. I have referred the code from this [link](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions)

```auto
exports.onExecutePostLogin = async (event, api) => {
	const userEmail = event.user.email;
	const userId = event.user.user_id;

	// This property will never be undefined in Actions.
	const userAppMetadata = event.user.app_metadata;

	// ... additional code
};

```

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [May 10, 2024, 5:38pm UTC](https://community.auth0.com/t/user-metadata-as-well-as-app-metadata-is-not-showing-as-part-of-acess-token-while-using-action-library/133852/3 "2024-05-10T17:38:26Z")

</div>

Hi @selvi,

This line of code `const userAppMetadata = event.user.app_metadata;` is used to get the user’s current app\_metadata information.

If you need to include the user\_metadata and app\_metadata in your access token, you would need to add them as a custom claim.

```auto
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://myapp.example.com';
if (event.authorization) {
    // Set claims in access token
    api.accessToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
    api.accessToken.setCustomClaim(`${namespace}/app_metadata`, event.user.app_metadata);
  }
};

```

(Reference: [Adding custom claims to tokens](https://community.auth0.com/t/adding-custom-claims-to-tokens/84590))

Thanks,  
Rueben

---

<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:** [May 24, 2024, 5:39pm UTC](https://community.auth0.com/t/user-metadata-as-well-as-app-metadata-is-not-showing-as-part-of-acess-token-while-using-action-library/133852/4 "2024-05-24T17:39:14Z")

</div>

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