-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token Renewal Fails in PWA (React) on iPad, Leading to User Disconnection or Stuck Unauthenticated State #1575
Comments
I think setting |
Thanks for the reply. Then thing is autoRemove is already set to false :
|
If
Have you observed this error in console logs or in your Okta Admin Sys Logs? |
Yes, I do see this in my monitoring tool. However, the issue is that all users are required to log out and log back in every day, which means a new refresh token is issued daily. So how can it be invalid or expired?
My Code: I’ve removed the listener for the expiration event because the app is used in locations with poor internet connectivity. When renewal failed, the tokens were getting wiped every time. Instead, I now renew the token only after receiving a 401, ensuring the user has internet access before attempting renewal. I also added a "Load fail" condition, which improves the situation but still feels like a bit of a hack:
|
Is code within your app signing users out? Are you certain a new refresh token is being obtained? Just to make sure I understand the issue:
Or do these errors occur when the user tries to sign in? |
Yes, when a user opens the app for the first time in a day, the code triggers a sign-out to force them to reconnect. My assumption is that when the user logs back in, a new token is issued—can you confirm if that is correct? Here’s the sequence of events: Does this behavior align with what you’d expect? Any insights would be appreciated. |
Also sometimes when we try to renew the token we get these errors too :
The app is mainly used as a PWA in an ipad BTW |
Describe the bug
Token renewal sometimes fails in a PWA running on an iPad, even though refresh tokens are configured with the offline_access scope. When this happens, the refresh token is deleted, leaving users either disconnected or unknowingly stuck in an unauthenticated state.
Reproduction Steps?
Initial Setup
• Configure refresh tokens with the offline_access scope enabled.
• Initially, set autoRenew to true. When the token expires offline, users get disconnected upon reconnecting.
Switch to Manual Renewal
• Set autoRenew to false and listen for token expiration events.
• Call renewTokens() when the event oktaAuth.tokenManager.on("expired") fires and navigator.onLine is true.
• Some users experience token renewal failure with this error, possibly due to network issues.
{ "name": "AuthApiError", "errorSummary": "Load failed" }
• Some affected users are in areas with very poor network connections.
Critical Issue: Refresh Token Deletion
• When renewTokens() fails, the refresh token is deleted, despite its 90-day lifetime and daily reissuance, this results in two cases:
- With third-party cookies blocked: /authorize request fails with the error :
{ "resp": null, "name": "OAuthError", "errorCode": "login_required", "errorSummary": "The client specified not to prompt, but the user is not logged in.", "error": "login_required", "error_description": "The client specified not to prompt, but the user is not logged in." }
- With third-party cookies enabled: The renewal sometimes works sometimes not.
• If a user closes the app indefinitely and later reopens it, failing to fetch encryption key data with a 401 error prevents the app from loading.
SDK Versions
7.10.1
Additional Information?
Any insights or guidance on how to improve the token renewal process would be greatly appreciated. Thank you !
The text was updated successfully, but these errors were encountered: