Session expired: Codex OAuth session expired
Quick fix
Upgrade to cc-switch v4.0.0 or later to prevent old snapshots from overwriting new login credentials.
Symptom
Section titled “Symptom”会话过期了The session has expired
Older versions could overwrite ~/.codex/auth.json with an old snapshot saved in the database when switching providers or refreshing usage. As a result, old data could replace the new token obtained through OAuth login. Another user reported that access_token and refresh_token were corrupted after logging in again. Issue #3570 also describes usage refresh failing because OAuth account storage and provider metadata were inconsistent. Maintainers confirmed that, starting with v4.0.0, replacing only key fields and removing backfilling resolves the old-snapshot overwrite mechanism.
Upgrade cc-switch to v4.0.0 or later; maintainers confirmed that this version includes the fix.
After upgrading, log in to Codex through OAuth again and re-enable usage refresh. If the issue still recurs, provide additional information and reopen the issue.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- How can I stop oauth.json from being overwritten with old data after disabling usage queries?
- Upgrade to v4.0.0 or later. Maintainers said that when switching providers, this version no longer overwrites the entire ~/.codex/auth.json with an old snapshot from the database.
- What should I do if the session still shows as expired after upgrading?
- Maintainers recommend providing more information about the problem and reopening the issue.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.