After using web login for GPT account successfully, then switching back to API token, 403 forbidden
Resolved 💬 1 comment Opened Aug 28, 2025 by bentito Closed Oct 28, 2025
What version of Codex is running?
v0.25.0
Which model were you using?
N/A
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
Run newer version of codex-cli
One time: accept to do the web-based GPT login
Next run: try to switch back to API token
Fails with 403 Forbidden
Workaround:
put at the top of your ~/.codex/config.toml
preferred_auth_method = "apikey"
Without the workaround, you cannot continue to use your API key (In my experience, up to and including v0.25.0
What is the expected behavior?
Allows to switch between web GPT login or using API key as desired
What do you see instead?
403 Forbidden on trying to use API key after once choosing GPT login option
Additional information
See workaround in description.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗