# getAccessTokenSilently results in a 403 when ignoreCache is set to true

**URL:** <https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806>\
**Category:** Get Help\
**Created:** [August 31, 2022, 8:18pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806 "2022-08-31T20:18:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [August 31, 2022, 8:18pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/1 "2022-08-31T20:18:27Z")

</div>

Please include the following information in your post:

- Which SDK this is regarding: Auth 0 React
- SDK Version: 1.10.20
- Platform Version: Windows 11
- 403 Error

In an effort to force reissue an access token, I have set ignoreCache to true. I am using refresh tokens and also set my cache location to local storage. The reason I am attempting to force reissue a refresh token is because I would like to refresh the access token before it actually expires. Is the issue caused by setting ignoreCache to true? Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 31, 2022, 11:14pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/3 "2022-08-31T23:14:21Z")

</div>

Hi @franz.salvador,

Welcome to the Auth0 Community!

Can you please share the entire error? There should be more information to help you understand what is going wrong.

---

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [September 1, 2022, 1:06am UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/4 "2022-09-01T01:06:45Z")

</div>

Hi Dan,

Here is the error.  
err = Error: Multifactor authentication required at new OAuthError  
Can this be related to setting the cacheLocation to “local storage”, then setting the _ignoreCache_ option to true when calling getTokenSilently?

If I set the _ignoreCache_ option to false, it works perfectly.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 1, 2022, 3:25pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/5 "2022-09-01T15:25:20Z")

</div>

> [@franz.salvador](#):
>
> Error: Multifactor authentication required

This error suggests the user must authenticate with their MFA to obtain a token. It isn’t possible to get a token silently when it requires user interaction (MFA).

Setting ignoreCache to `true` means that the SDK must reach out to Auth0 for a new token, and can’t used a token that already exists in the cache.

Here’s a thread on how you can handle this situation:

> [@Failed Silent Auth. Multifactor authentication required error](https://community.auth0.com/t/failed-silent-auth-multifactor-authentication-required-error/46923/3):
>
> Experiencing the same issue with an angular app. Implementing the rule that is referenced above and in a few places throughout the boards did not resolve the issue for me either.

---

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [September 1, 2022, 5:56pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/6 "2022-09-01T17:56:14Z")

</div>

I see. Thanks for your help Dan!

---

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [September 1, 2022, 6:14pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/7 "2022-09-01T18:14:38Z")

</div>

So just to confirm, there is no way to get the token silently when MFA is enabled? MFA is one of our requirements. When I initially login it works. When I try to get a new access token, that’s when I receive an error. Thanks again for your help.

---

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [September 1, 2022, 8:18pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/8 "2022-09-01T20:18:16Z")

</div>

I saw the post about setting up a rule for MFA to occur only once per session. I’ll try and implement now. Disregard last post.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 1, 2022, 8:33pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/9 "2022-09-01T20:33:14Z")

</div>

Sounds good, let us know what you find.

---

<div class="post-metadata">

**Author:** ![franz.salvador](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/franz.salvador/32/33622_2.png) [@franz.salvador](https://community.auth0.com/u/franz.salvador)\
**Post date:** [September 2, 2022, 6:37pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/10 "2022-09-02T18:37:58Z")

</div>

Works like a charm. The only issue that needed to be addressed is detecting if the client is calling getTokenSilently and has a refresh token. In order to check this, we needed to check _context.protocol_. If refresh token is used, bypass mfa athentication since the refresh token has been granted. We are running node 12 so code may seem a bit outdated.

```auto
  const requiresMfa = function (context, user) {
    const refreshTokenProtocol = 'oauth2-refresh-token';
    const isRefreshTokenProtocol = context.protocol === refreshTokenProtocol;

    let authMethods = [];
    if (context.authentication && Array.isArray(context.authentication.methods)) {
      authMethods = context.authentication.methods;
    }
    const isMFAAuthenticated = Boolean(authMethods.find(method => method.name === 'mfa'));

    if (isRefreshTokenProtocol || isMFAAuthenticated) {
      return false;
    }
    return true;
  };

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 2, 2022, 9:15pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/11 "2022-09-02T21:15:39Z")

</div>

Perfect. Thanks for the explainer and code sample 🙌

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 30, 2022, 11:03pm UTC](https://community.auth0.com/t/getaccesstokensilently-results-in-a-403-when-ignorecache-is-set-to-true/89806/12 "2022-09-30T23:03:52Z")

</div>


