Skip to content

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.

Error output
会话过期了
English translation

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.

  1. Upgrade cc-switch to v4.0.0 or later; maintainers confirmed that this version includes the fix.

  2. 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.

ToolCodex
Version3.16.1、3.20.0(受影响);v4.0.0 起已修复
PlatformsWindows

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.

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.