thready
November 10, 2023, 6:59pm
1
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
tyf
November 13, 2023, 9:34pm
4
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:
# Auth0-React v2 Migration Guide
With the v2 release of Auth0-React we have updated to the latest version of Auth0-SPA-JS which brings improvements to performance and developer experience. However, as with any major version bump there are some breaking changes that will impact your applications.
Please review this guide thoroughly to understand the changes required to migrate your application to v2.
- [Polyfills and supported browsers](#polyfills-and-supported-browsers)
- [Public API Changes](#public-api-changes)
- [Introduction of `authorizationParams`](#introduction-of-authorizationparams)
- [Introduction of `logoutParams`](#introduction-of-logoutparams)
- [`buildAuthorizeUrl` has been removed](#buildauthorizeurl-has-been-removed)
- [`buildLogoutUrl` has been removed](#buildlogouturl-has-been-removed)
- [`redirectMethod` has been removed from `loginWithRedirect`](#redirectmethod-has-been-removed-from-loginwithredirect)
- [`localOnly` logout has been removed, and replaced by `openUrl`](#localonly-logout-has-been-removed-and-replaced-by-openUrl)
- [`ignoreCache` on `getAccessTokenSilently` has been removed and replace with `cacheMode`](#ignorecache-on-getaccesstokensilently-has-been-removed-and-replace-with-cachemode)
- [`application/x-www-form-urlencoded` used by default instead of `application/json`](#applicationx-www-form-urlencoded-used-by-default-instead-of-applicationjson)
- [No more iframe fallback by default when using refresh tokens](#no-more-iframe-fallback-by-default-when-using-refresh-tokens)
- [Changes to default scopes](#changes-to-default-scopes)
- [`advancedOptions` and `defaultScope` are removed](#advancedoptions-and-defaultscope-are-removed)
- [Removal of `claimCheck` on `withAuthenticationRequired`](#removal-of-claimcheck-on-withauthenticationrequired)
This file has been truncated. show original
@thready this may or may not be what you are running into as well.
Thanks, switching to {cacheMode: ‘off’} solved my issue!
1 Like
tyf
November 15, 2023, 12:37am
6
That’s great @ritchike , thanks for confirming!
system
Closed
November 29, 2023, 12:37am
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.