fix: refresh expired ID tokens before account switch - #134
Merged
Conversation
Codex can reject an expired ID token while the access token is still valid. Refresh both OAuth tokens before writing auth.json, preserve rotated refresh tokens on partial responses, and serialize rapid tray selections so the last request wins.
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.
Dependency
This is a stacked follow-up to #128. Please merge #128 first; this PR preserves its original commits and authorship. Once #128 lands, the remaining diff is the single follow-up commit daac4b6.
What changed
Why
On Windows with Codex desktop 26.820.9563.0, a stored account had an ID token that expired hours earlier while its access token remained valid. Codex Switcher only checked the access token and restored the stale ID token, after which Codex returned 401 and displayed the sign-in screen. PR #128 fixes live-token reconciliation; this follow-up covers the independent partial-expiry path and switch-time refresh.
Checks
Manual A to B to A switching was not run inside this active Codex task because the switcher correctly requires Codex to be closed first. The original failure was confirmed from local token expiry metadata and desktop authentication logs without publishing credentials.
Related: #127, #128, #129