# Auth Error after updating app\_metadata via Management API and injecting metadata to IdToken

**URL:** <https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [December 30, 2021, 2:59pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632 "2021-12-30T14:59:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmjun2000](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gmjun2000/32/34086_2.png) [@gmjun2000](https://community.auth0.com/u/gmjun2000)\
**Post date:** [December 30, 2021, 2:59pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/1 "2021-12-30T14:59:58Z")

</div>

Hi guys, following “thread”. I have a similar issue but in this case i am updating user\_metadata and adding the metadata to IdToken in a rule.

Is this happening because the token get modified? I am not updating email\_verified in my case.

Regards and thank you

Thread: [Silent Auth errors with Login Required after updating app\_metadata via Management API](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834)

---

<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:** [December 30, 2021, 6:24pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/2 "2021-12-30T18:24:33Z")

</div>

Hi @gmjun2000,

Welcome to the Auth0 Community!

Before we continue, could you please elaborate what are the errors you are getting?

And, could you please share your Rule for adding the _user\_metadata_ to the ID Token?

Thank you.

---

<div class="post-metadata">

**Author:** ![gmjun2000](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gmjun2000/32/34086_2.png) [@gmjun2000](https://community.auth0.com/u/gmjun2000)\
**Post date:** [January 2, 2022, 6:06pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/4 "2022-01-02T18:06:13Z")

</div>

Hi @rueben.tiow thank you for your response.  
With `checkSession({ ignoreCache: true })` just log me out and `getTokenSilently({ ignoreCache: true })` i get `Login required`.

My rule:

```auto
function migrateRootAttributes(user, context, cb) {
  var namespace = "https://e4s.systems/"; 
  context.idToken[namespace + "metadata"] = user.user_metadata;
  context.accessToken[namespace + "metadata"] = user.user_metadata;
  cb(null, user, context);
 
}

```

---

<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:** [January 3, 2022, 6:23pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/5 "2022-01-03T18:23:02Z")

</div>

Hi @gmjun2000,

Thank you for your reply.

First, the `Login required` error is expected when using the `getTokenSilently` method when there isn’t an authenticated user. In silent authentication, the “login required” error is thrown when the user’s browser does not or cannot send the “Auth0” cookie. This cookie identifies the user’s logged-in session with Auth0 and resides on the client’s browser.

In this case, you’ll need to initiate the authentication process again.

As for your Rule, it is correct for appending custom claims to tokens and should work.

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![gmjun2000](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gmjun2000/32/34086_2.png) [@gmjun2000](https://community.auth0.com/u/gmjun2000)\
**Post date:** [January 7, 2022, 11:49pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/6 "2022-01-07T23:49:24Z")

</div>

Hi @rueben.tiow. What could be the reason why i get revoked the token? The token is fresh and recently created.

---

<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:** [January 11, 2022, 8:32pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/7 "2022-01-11T20:32:43Z")

</div>

Hi @gmjun2000,

Thank you for your response.

I have made an edit to my previous post. The error you have encountered happens because it expects an authenticated user when using the `getTokenSilently` method.

As a result, you will need to make sure the user is logged in, or you will need to reinitiate the log-in process. Additionally, you might want to avoid the `checkSession({ ignoreCache: true })` logging you out preceding the `getTokenSIlently` method.

Hoped this helps!

Please let me know if there’s anything else I can do to help.

Thanks.

---

<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:** [January 26, 2022, 8:33pm UTC](https://community.auth0.com/t/auth-error-after-updating-app-metadata-via-management-api-and-injecting-metadata-to-idtoken/75632/8 "2022-01-26T20:33:24Z")

</div>

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