feature: [ANDROSDK-2372] identify expired or missing OAuth2 tokens - #2696
Open
taridepaco wants to merge 6 commits into
Open
feature: [ANDROSDK-2372] identify expired or missing OAuth2 tokens#2696taridepaco wants to merge 6 commits into
taridepaco wants to merge 6 commits into
Conversation
refresh both tokens if access token expired
andresmr
previously approved these changes
Aug 14, 2026
andresmr
approved these changes
Aug 14, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The SDK can now tell the app when an OAuth2 session is no longer usable. A new
D2ErrorCode.OAUTH2_NO_VALID_TOKENis thrown when there is no OAuth2 state, no access token, no refresh token, or when the server explicitly rejects the refresh token, and also on login for an account registered as OAUTH2 that has no tokens on this device (for example, after importing a database). Token rotation is now centralized inOAuth2TokenRefresher.rotate, which serializes concurrent refreshes with a mutex and returns aRefreshResultdistinguishing success, a retryable failure, and an unrecoverable one.The distinction matters because the previous implementation logged the user out on any refresh failure, including transient ones: going offline or hitting a server error closed the session. Now only a 400/401 from the token endpoint discards the stored tokens; anything else leaves the credentials untouched and the caller sees the original 401 so it can retry later. Proactive refreshing based on
expiresAtwas dropped along withOAuth2State.needsTokenRefresh()— refresh is driven by the actual 401 response instead, which also removes the reliance on device clock accuracy.Related task: ANDROSDK-2372