Reputation: 1
I am using react-oidc-context with oidc-client-ts for keycloak authentication.
Oidc-client-ts provides automaticSilentRenew setting, and it's working fine when the tab is inactive or active. I always get a new token prior to 1 minute of access token expiry.
But when my computer goes into sleep mode and session idle time is out, then somehow, oidc-client-ts doesn't handle automatic silent renewal. Upon wake up from sleep mode, I get a token that is not an active error. Even if I reload the page, I still get the same error, and I have to end up closing the current tab and reopening it in a new tab.
How do I do automatic silent renewal in sleep mode also when session idle time is out?
I tried the below solution, and it's working with sleep mode as well, but signinSilent is causing the page to rerender. So, if some user is filling the form, and is halfway in submitting, then everything will be cleared, so I cannot use this.
useEffect(() => {
auth.events.addAccessTokenExpiring((error) => {
auth.signinSilent().then(u => {
console.log("signin user addAccessTokenExpiring", u)
}).catch(er => {
console.log(er)
})
})
}, [auth])
Upvotes: 0
Views: 717