<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D51Y00009sozGwSAIOkta Classic EngineOkta Integration NetworkAnswered2023-10-09T21:54:52.000Z2020-11-13T22:18:36.000Z2020-11-17T02:35:13.000Z

PavanB.10823 (Customer) asked a question.

how to silent renew tokens in react SPA

Hi,

i am trying to integrate OKTA into my react application and stumbled at renewal token part. i have looked for documentation but couldn't find any working example. after going through couple questions posted by other people i ended up with following config.

 

const config = {

    issuer: process.env.REACT_APP_OKTA_ORG_URL,

    redirect_uri: `${window.location.origin}/implicit/callback`,

    client_id: process.env.REACT_APP_OKTA_CLIENT_ID,

    scope: ['openid', 'profile', 'email', 'groups'],

    pkce: true,

    cookies: {

      secure: window.location.protocol === 'https:',

    },

    tokenManager: {

      autoRenew: true,

      secure: true,

      storage: 'localStorage',

    }

  };

 

 

 <Router>

      <Security {...config}>

<App />

</Security>

</Router >

 

 

is this setting enough to auto renew tokens silently without asking user to re login every time ?

or is there any method or hooks available to capture the session expiration event something like below .

 

<below is just an example was assuming something like below is already available >

 

const onSessionExpired = ()=>{

authState.renew();

}

 

 

 


This question is closed.
Loading
how to silent renew tokens in react SPA