codex session expired - Codex
Quick fix
Back up the config, then sync the auth.json token into the cc-switch database with a script, or turn usage refresh off so old data cannot overwrite it.
Symptom
Section titled “Symptom”codex 会话已过期codex session expired
cc-switch stores Codex OAuth data in three places: codex_oauth_auth.json, ~/.codex/auth.json, and cc-switch.db. Early version upgrades did not migrate the providerType and authBinding fields, and with usage refresh enabled old data could overwrite the newer oauth.json — leaving the three out of sync, with wrong front-end routing or an invalid token. Separately, when several accounts in the same Team sign in, deduplication logic keyed on the Team ID also lets one account overwrite another.
Run codex login in a terminal to make sure the OAuth token in ~/.codex/auth.json is valid, then quit cc-switch fully from the menu bar.
Back up codex_oauth_auth.json and cc-switch.db from the config directory.
Run a Python script to extract the token from ~/.codex/auth.json into codex_oauth_auth.json, then locate the official codex provider and fill in the providerType and authBinding fields in cc-switch.db. The target file structure is as follows:
~/Documents/configs/cc-switch/codex_oauth_auth.json {"version": 1,"accounts": {"<account_id>": {"account_id": "<account_id>","email": "<email>","refresh_token": "<refresh_token>","authenticated_at": <timestamp>}},"default_account_id": "<account_id>"}Restart cc-switch. If enabling usage refresh overwrites oauth.json with old data, turn the usage query feature off for now after signing in with OAuth again.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 5 real issues
- After authenticating several official accounts in the same Team, why does only the last one signed in survive?
- The account deduplication logic appears to key on a Team or workspace ID rather than the real ChatGPT account ID, so a later login in the same Team overwrites the earlier one.
- After signing in to Codex again, why does enabling usage refresh report the session as expired?
- With usage refresh on, cc-switch may overwrite the latest oauth.json with cached old data. Turn the usage query feature off for now after signing in again.
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.