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

Why there will trigger multiple refresh token endpoint?.?

Open wingosite opened this issue 1 year ago • 4 comments

Hi, When I change the scope after login with signinRedirect(). like this:

useEffect(()=>{
    if(auth.isAuthenticated && !auth.isLoading){
         signinRedirect({
             redirect_uri: xxx,
             scope: scope
         })
    }
},[auth,scope])

However, after change the scope, there will trigger multiple token endpoint when renew the token. like this: image

Token expired in different times image

any idea for this issue? Thanks in advance...!

wingosite avatar Nov 20 '23 08:11 wingosite

Logging might give you some insights: https://authts.github.io/oidc-client-ts/#md:logging

Maybe (React StrictMode](https://react.dev/reference/react/StrictMode) is tricking you?

pamapa avatar Nov 20 '23 08:11 pamapa

Thanks for reply. It works as expected when React StrictMode disabled But it will trigger multiple refresh token endpoint when React StrictMode enable, is there any way to fix it..?

wingosite avatar Nov 21 '23 02:11 wingosite

Thanks for reply. It works as expected when React StrictMode disabled But it will trigger multiple refresh token endpoint when React StrictMode enable, is there any way to fix it..?

This is only a problem for development/debug, you can handle it like proposed by the React markers: https://github.com/facebook/react/issues/24502#issuecomment-1118867879

pamapa avatar Nov 21 '23 15:11 pamapa

hi @wingosite,

React 18 renders twice in development mode, u can remove StrictMode in your index,js or index.ts



root.render(
  <>
    <Provider store={store}>
        <CustomThemeProvider>
          <CssBaseline />
        </CustomThemeProvider>
    </Provider>
  </>
);

I have one question; I am not able to implement proper redirection. My application is redirecting infinitely. Can you show an example?

ajmaln-tw avatar Dec 12 '23 07:12 ajmaln-tw