# Migrating rule Adding user details to access token to action

**URL:** <https://community.auth0.com/t/migrating-rule-adding-user-details-to-access-token-to-action/84270>\
**Category:** Get Help\
**Tags:** jwt, login, auth0\
**Created:** [May 30, 2022, 4:28pm UTC](https://community.auth0.com/t/migrating-rule-adding-user-details-to-access-token-to-action/84270 "2022-05-30T16:28:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlfreymond](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jlfreymond/32/36172_2.png) [@jlfreymond](https://community.auth0.com/u/jlfreymond)\
**Post date:** [May 30, 2022, 4:28pm UTC](https://community.auth0.com/t/migrating-rule-adding-user-details-to-access-token-to-action/84270/1 "2022-05-30T16:28:53Z")

</div>

Hello,  
I have a rule that adds the app\_metadata to the Access Token.

function addEmailToAccessToken(user, context, callback) {  
var namespace = ‘[https://xyz.com/](https://xyz.com/)’;  
context.accessToken[namespace + ‘app\_metadata’] = user.app\_metadata;  
return callback(null, user, context);  
}

For some reason, it appears user.metadata is not available in the M2M Actions context.

Can you please advise on how to migrate this feature to Actions?  
Thanks

---

<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 31, 2022, 9:36pm UTC](https://community.auth0.com/t/migrating-rule-adding-user-details-to-access-token-to-action/84270/3 "2022-05-31T21:36:15Z")

</div>

Hi @jlfreymond,

Welcome to the Auth0 Community!

Firstly, please see our [Migrate from Rules to Actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions) docs for more information on migrating from Rules to Actions.

> [@jlfreymond](#):
>
> For some reason, it appears user.metadata is not available in the M2M Actions context.
> 
> Can you please advise on how to migrate this feature to Actions?

When authenticating against a M2M (client credentials grant flow), it is not interactive and does not require any user interaction. Therefore when using the [Machine to Machine Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/machine-to-machine-flow) flow, there is no `event.user` object.

Here are some helpful documentation:

- [Actions Triggers: credentials-exchange - Event Object](https://auth0.com/docs/customize/actions/flows-and-triggers/machine-to-machine-flow/event-object)
- [Actions Triggers: credentials-exchange - API Object](https://auth0.com/docs/customize/actions/flows-and-triggers/machine-to-machine-flow/api-object)
- [Login Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow#add-user-roles-to-id-and-access-tokens)

Hoped this helps!

Please let me know if you have any questions.

Thank you.

---

<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:** [December 22, 2022, 9:27am UTC](https://community.auth0.com/t/migrating-rule-adding-user-details-to-access-token-to-action/84270/4 "2022-12-22T09:27:42Z")

</div>


