-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Hello,
We are using withAuthenticationRequired to protect most of the routes in our React applications. We’ve noticed that when a previously authenticated user returns to the app with an expired access token, they are always redirected to the IDP login page, even though a valid refresh token is still available in their local storage.
It seems this behavior is intentional, as the current implementation in withAuthenticationRequired.tsx does not attempt to silently renew the access token before calling signinRedirect.
I would expect the library to try renewing the access token using the refresh token (if available) before prompting the user to log in again explicitly.
Is there a way to achieve this behavior with the current implementation ? If not, could we add an optional prop to withAuthenticationRequired that enables attempting signinSilent before calling signinRedirect?
For reference, this is our current configuration :
const config: AuthProviderProps = {
authority: import.meta.env.VITE_COGNITO_AUTHORITY,
client_id: import.meta.env.VITE_COGNITO_CLIENT_ID,
redirect_uri: import.meta.env.VITE_COGNITO_CALLBACK_URL,
automaticSilentRenew: true,
response_type: 'code',
scope: 'email openid profile',
userStore: new WebStorageStateStore({ store: window.localStorage }),
extraQueryParams: {
lang: getCurrentLanguagePreference(),
},
onSigninCallback: () => {
...
},
};