# Silent Auth errors with Login Required after updating app\_metadata via Management API

**URL:** <https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834>\
**Category:** Get Help\
**Tags:** app\_metadata, silent-auth\
**Created:** [July 8, 2021, 7:13pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834 "2021-07-08T19:13:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spatail](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spatail/32/27908_2.png) [@spatail](https://community.auth0.com/u/spatail)\
**Post date:** [July 8, 2021, 7:13pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/1 "2021-07-08T19:13:33Z")

</div>

Hello,

I am trying to understand why calling `getAccessTokenSilently` redirects me back to the login page after I update my user’s `app_metadata` via the Management API.

Here’s my setup:

1. I have two applications: 1) an SPA, and 2) a M2M
2. The SPA shows the Auth0 login screen and upon successful signup/login redirects back to my application
3. After redirecting, the user is requested to enter an invite code (from their email) to link the Auth0 user to my backend domain model
4. The SPA invokes my backend with the invite code. The backend uses the M2M client credentials to call the Management API to enhance the logged-in user’s app\_metadata with a linking id
5. I also have a Rule defined which upon login/silent-auth will append the app\_metadata as a custom claim in the new access token
6. After the backend call completes, the SPA requests a new access token via silent-auth. This is so that all subsequent backend calls will be made with a new token that contains the custom claim.

The issue I am facing is that when requesting a new token via silent-auth (after the backend call), the SPA gets a “login required” error and gets redirected back to the Auth0 login page.

Now what’s odd is that if I update the user’s app\_metadata directly in Auth0 and then have the SPA request a new access token, it’s all hunky dory. But if I update the same user via the Management API, a request for a new token fails and requires a re-login.

Is there a difference in the way Auth0 handles updating a user directly from the Auth0 UI vs the Management API? Why does silent-auth work just fine in the former case, but does not work in the latter case?

I feel like I am missing something fundamental. Any help here would be much appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![spatail](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spatail/32/27908_2.png) [@spatail](https://community.auth0.com/u/spatail)\
**Post date:** [July 8, 2021, 7:53pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/2 "2021-07-08T19:53:26Z")

</div>

If it helps, here’s a sequence diagram of my registration flow:

 ![registration-flow](https://global.discourse-cdn.com/auth0/original/3X/e/e/ee49f30edb3cc33178f442dd7412dc1ec6f9db2b.png)

---

<div class="post-metadata">

**Author:** ![spatail](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spatail/32/27908_2.png) [@spatail](https://community.auth0.com/u/spatail)\
**Post date:** [July 13, 2021, 9:27pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/3 "2021-07-13T21:27:31Z")

</div>

Any suggestions here? The difference in behavior of silent-auth (when updating app\_metadata via the Management API vs updating via the UI) is quite puzzling.

The UX of of having to re-login is what I am trying to avoid.

Thanks!

---

<div class="post-metadata">

**Author:** ![marcus.baker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcus.baker/32/8586_2.png) [@marcus.baker](https://community.auth0.com/u/marcus.baker)\
**Post date:** [July 23, 2021, 6:41pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/4 "2021-07-23T18:41:31Z")

</div>

Hi,

Is your backend updating the **email** or **email\_verified** attributes when it patches the user?  
Patching Email or Email\_verified via the management API will invalidate the Auth0 session.

Example:

This post body will invalidate the session:

```auto
{
  "email_verified": true,
  "app_metadata": {
          "TestData": "TestValue"
        }
}

```

This one works without invalidating the session:

```auto
{
  "app_metadata": {
          "TestData": "TestValue"
        }
}

```

---

<div class="post-metadata">

**Author:** ![spatail](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spatail/32/27908_2.png) [@spatail](https://community.auth0.com/u/spatail)\
**Post date:** [July 23, 2021, 6:55pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/5 "2021-07-23T18:55:23Z")

</div>

Yes, my backend was setting `email_verified: true`. After removing it, my frontend is able to refresh the token silently without getting the login required error.

Thanks Marcus!

Would you mind explaining why toggling `email_verified` invalidates the session? Is this shared in the docs anywhere?

---

<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:** [August 7, 2021, 6:56pm UTC](https://community.auth0.com/t/silent-auth-errors-with-login-required-after-updating-app-metadata-via-management-api/65834/6 "2021-08-07T18:56:02Z")

</div>

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