Error 403 - invalid_grant - Unknown or invalid refresh token - SPA ReactJS

I had to enable the use of “refresh token” for it to work properly in Safari and Brave.
I have this config in my index.js

const providerConfig = {
  domain: auth0Domain,
  clientId: auth0ClientId,
  audience: auth0Audience,
  redirectUri: auth0Redirect,
  onRedirectCallback
};

ReactDOM.render(
  <Auth0Provider
    {...providerConfig}
    useRefreshTokens={true}
    cacheLocation="localstorage"
  >
    <ThemeProvider theme={theme}>
      <Provider store={store}>
        <App />
      </Provider>
    </ThemeProvider>
  </Auth0Provider>,
  document.getElementById("root")
);

My config in Application Auth0.

Sometimes I don’t understand why the token refresh request fails
This problem occurs occasionally and in any browser.

Captura de Pantalla 2022-08-18 a la(s) 22.28.45

I don’t understand why it happens.

References:

Status 403
…/oauth/token in SPA

The error is caused by the inactivity expiration. When enabled, a refresh_token will expire based on a specified duration of inactivity, after which the token can no longer be used.

1 Like