oidc-client icon indicating copy to clipboard operation
oidc-client copied to clipboard

Silent Access token Refresh is not working. it is redirecting to authentication provider every 3-4 min while we have 15min timeout for accesstoken.

Open mohitthakur23 opened this issue 1 year ago • 5 comments

Issue and Steps to Reproduce

using following configuration..

const configurationIdentityServer = { client_id: 'client_id', redirect_uri: ${window.location.origin}/authentication/callback, silent_redirect_uri:${window.location.origin}/authentication/silent-callback, silent_login_uri: window.location.origin + '/authentication/silent-login', // silent_login_timeout: 3600, // Optional default is 12000 milliseconds scope: 'openid profile email offline_access', response_type: 'code', automaticSilentRenew: true, authority: stsauthority(), refresh_time_before_tokens_expiration_in_second: 60, service_worker_relative_url: '/OidcServiceWorker.js', service_worker_only: false, post_logout_redirect_uri: ${window.location.origin}, token_renew_mode: TokenRenewMode.access_token_invalid, };

Versions

"@axa-fr/react-oidc": "^6.22.0",

Screenshots

image

Expected

access_token should be renewed in background. without affecting onscreen tasks

Actual

Every 5 min it is redirecting to Authentication Provider and coming back , and showing error "An error Occured During Authentication".

mohitthakur23 avatar Jun 23 '23 11:06 mohitthakur23

hi @mohitthakur23 ,

Thank you for your issue, i may need more information what can help. do you have network error, or something in your debug console ?

does refresh_token is returned by the first request ?

guillaume-chervet avatar Jun 23 '23 16:06 guillaume-chervet

hi, @guillaume-chervet I did a few modifications with the latest library version here is my latest config.->

const configurationIdentityServer = { client_id: 'client_id', redirect_uri: ${window.location.origin}/authentication/callback, silent_redirect_uri:${window.location.origin}/authentication/silent-callback, scope: 'openid profile email', response_type: 'code', automaticSilentRenew: true, authority: stsauthority(), refresh_time_before_tokens_expiration_in_second: 160, service_worker_relative_url: '/OidcServiceWorker.js', service_worker_only: false, post_logout_redirect_uri: ${window.location.origin}, token_renew_mode: TokenRenewMode.access_token_invalid }; it helped me do a silent refresh one time, but soon after it gives me the same error again with the console error "invalid state".

here is the flow - we have an access token timeout of 15 min after 12-13min of successful login into the application, service-worker starts a silent-callback request it gets successful. after successful updations of the token when the service-worker sends another request, it gives the above error. any help will be appreciated.

mohitthakur23 avatar Jun 26 '23 12:06 mohitthakur23

hi @mohitthakur23 ,

what is your oidc server?

may you given the content of the last token request ?

"State is not valid" seem to come from react oidc. I need more information to understand. Do you have this error if your remove service worker and uninstall from console debug mode?

guillaume-chervet avatar Jun 27 '23 16:06 guillaume-chervet

hi @guillaume-chervet
we have disabled service-worker in configuration, and it worked fine till today, but today we again got an invalid state error. we have also noticed when we get this error ,browser is kind of stuck( showing redirected uri from auth server with authorization code) untill we reopen it in new tab.

mohitthakur23 avatar Jul 03 '23 13:07 mohitthakur23

hi @mohitthakur23 , do you have service worker well unregistered ?

Do you have more information? a video?

guillaume-chervet avatar Jul 04 '23 07:07 guillaume-chervet