Open juztinlazaro opened 3 weeks ago
Subscribes a callback that will be called when the authStateChange event happens. not triggering after 1hr token expiration or idle mode
version:
"@okta/okta-auth-js": "7.8.1", "@okta/okta-react": "6.9.0", "@okta/okta-signin-widget": "7.24.2",
export const getOktaAuth = () => { return new OktaAuth({ clientId: OKTA_CLIENT_ID, redirectUri: `${window.location.origin}/authorization-code/callback`, useClassicEngine: true, issuer: `${OKTA_API_BASE}/oauth2/${OKTA_AUTH_SERVER}`, pkce: true, url: OKTA_API_BASE, tokenManager: { storageKey: 'mycrm-tokens', }, transformAuthState: async (oktaAuth, authState) => { if (!authState.isAuthenticated || !!authState.oktaUser) { return authState; } const user = await oktaAuth.token.getUserInfo(); authState.isAuthenticated = !!user; authState.oktaUser = user; return authState; }, }); };
export const onRefreshExpirationToken = async () => { // trigger every 1hr const oktaAuth = getOktaAuth(); oktaAuth.authStateManager.subscribe(async (authState) => { console.log("authState==", authState); if (authState.isAuthenticated) { const newToken = authState.accessToken?.accessToken; LocalStorageProxy.token = newToken; } }); oktaAuth.authStateManager.updateAuthState(); };
No response
fixed by adding oktaAuth.start(); https://github.com/okta/okta-auth-js?tab=readme-ov-file#running-as-a-service
oktaAuth.start()
Describe the bug
Subscribes a callback that will be called when the authStateChange event happens. not triggering after 1hr token expiration or idle mode
version:
Reproduction Steps?
SDK Versions
version:
Additional Information?
No response