getAccessTokenSilently with ignoreCache still giving me old token

I’m doing a rest call that adds roles to a user on the backend. After that call, I’m trying to get a new token which will have those roles injected.

         await rest_call();

        const refreshedAccessToken = await getAccessTokenSilently({
            scope: "openid profile email offline_access",
            ignoreCache: true,
        });

But even with ignoreCache, the token returned is the one that I already had locally. There is no network request to auth0 at all, so it’s for sure ignoring the “ignoreCache: true” for the call for some reason.

I’ve setup my Auth0provider with this config:

  const providerConfig = {
      domain: config.domain,
      clientId: config.clientId,
      useRefreshTokens: true,
      cacheLocation: "localstorage",
      onRedirectCallback,
      authorizationParams: {
          redirect_uri: window.location.origin,
          ...(config.audience ? { audience: config.audience } : null),
      },
  };

Any idea why ignoring cache seems to have no effect? Many thanks.

1 Like

I am having the same problem. This used to work, but I have upgraded auth0 and made several other changes over time so hoping not to have to unwind those to figure this out. Was on @auth0/auth0-react 1.10.1 and upgraded to 2.2 among a bunch of other changes before noticing this issue

Hey there @ritchike welcome to the community!

Thanks for specifying the versions in use - ignoreCache was removed in version 2+ in favor of cacheMode. Please see:

@thready this may or may not be what you are running into as well.

Thanks, switching to {cacheMode: ‘off’} solved my issue!

1 Like

That’s great @ritchike, thanks for confirming!

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