Description
Summary
OpenCode fails to complete OpenAI authentication via OpenAI -> ChatGPT Pro/Plus (browser).
The browser authorization flow appears to complete, and the local OAuth callback server starts correctly on localhost:1455, but token exchange fails with:
Token exchange failed: 403
As a result, no OpenAI credential is written to the local auth file.
Environment
- OpenCode version:
1.2.19
- OS: macOS
- Installation method: Homebrew CLI
- Running locally on desktop (not SSH / remote / container / WSL)
What I did
- Installed / upgraded OpenCode CLI
- Ran:
-
Selected:
- Provider:
OpenAI
- Login method:
ChatGPT Pro/Plus (browser)
-
Completed authorization in browser
Expected behavior
After browser authorization, OpenCode should exchange the authorization code for tokens successfully and write the OpenAI credential locally.
Actual behavior
OpenCode waits for authorization, then fails with:
Error: Unexpected error, check log file for more details
Token exchange failed: 403
No OpenAI credential is added to the local auth file.
Relevant log output
INFO service=plugin.codex port=1455 codex oauth server started
ERROR service=default name=Error message=Token exchange failed: 403 stack=Error: Token exchange failed: 403
at exchangeCodeForTokens (src/plugin/codex.ts:125:15)
at processTicksAndRejections (native:7:39) fatal
Full log excerpt:
INFO 2026-03-06T05:06:52 +598ms service=default version=1.2.19 args=["auth","login"] opencode
INFO 2026-03-06T05:06:52 +1ms service=default directory=<REDACTED_HOME> creating instance
INFO 2026-03-06T05:06:52 +0ms service=project directory=<REDACTED_HOME> fromDirectory
INFO 2026-03-06T05:06:52 +0ms service=db path=<REDACTED_HOME>/.local/share/opencode/opencode.db opening database
INFO 2026-03-06T05:06:52 +16ms service=db count=6 mode=bundled applying migrations
INFO 2026-03-06T05:06:52 +233ms service=config path=<REDACTED_HOME>/.config/opencode/config.json loading
INFO 2026-03-06T05:06:52 +1ms service=config path=<REDACTED_HOME>/.config/opencode/opencode.json loading
INFO 2026-03-06T05:06:52 +5ms service=config path=<REDACTED_HOME>/.config/opencode/opencode.jsonc loading
INFO 2026-03-06T05:06:52 +23ms service=plugin name=CodexAuthPlugin loading internal plugin
INFO 2026-03-06T05:06:52 +0ms service=plugin name=CopilotAuthPlugin loading internal plugin
INFO 2026-03-06T05:06:52 +0ms service=plugin name=gitlabAuthPlugin loading internal plugin
INFO 2026-03-06T05:06:52 +0ms service=plugin path=opencode-anthropic-auth@0.0.13 loading plugin
INFO 2026-03-06T05:06:52 +25ms service=plugin path=file://<REDACTED_HOME>/.config/opencode/plugins/usage-telemetry.ts loading plugin
INFO 2026-03-06T05:07:04 +11621ms service=plugin.codex port=1455 codex oauth server started
ERROR 2026-03-06T05:08:06 +61623ms service=default name=Error message=Token exchange failed: 403 stack=Error: Token exchange failed: 403
at exchangeCodeForTokens (src/plugin/codex.ts:125:15)
at processTicksAndRejections (native:7:39) fatal
Auth file state
The local auth file is not updated with any OpenAI credential after the flow completes.
Current contents only show another provider entry, for example:
{
"minimax-cn-coding-plan": {
"type": "api",
"key": "REDACTED"
}
}
Additional notes
localhost:1455 is listening correctly during the flow
- This is not caused by an outdated CLI version
- This is not a remote environment issue
- Browser authorization appears to succeed, but token exchange returns 403
- Happy to test a patched build or provide more logs if needed
Plugins
Internal auth plugins plus: - opencode-anthropic-auth@0.0.13 - usage-telemetry.ts The issue is specifically with OpenAI -> ChatGPT Pro/Plus browser auth.
OpenCode version
1.2.19
Steps to reproduce
- Install or upgrade OpenCode CLI to v1.2.19.
- Run
opencode auth login.
- Select provider: OpenAI.
- Select login method: ChatGPT Pro/Plus (browser).
- Complete authorization in the browser.
- Return to the terminal and observe the error:
Token exchange failed: 403.
- Check local auth state: no OpenAI credential is written to the auth file.
Screenshot and/or share link
No response
Operating System
macOS 26.3.1
Terminal
Terminal.app
Description
Summary
OpenCode fails to complete OpenAI authentication via OpenAI -> ChatGPT Pro/Plus (browser).
The browser authorization flow appears to complete, and the local OAuth callback server starts correctly on
localhost:1455, but token exchange fails with:Token exchange failed: 403As a result, no OpenAI credential is written to the local auth file.
Environment
1.2.19What I did
Selected:
OpenAIChatGPT Pro/Plus (browser)Completed authorization in browser
Expected behavior
After browser authorization, OpenCode should exchange the authorization code for tokens successfully and write the OpenAI credential locally.
Actual behavior
OpenCode waits for authorization, then fails with:
No OpenAI credential is added to the local auth file.
Relevant log output
Full log excerpt:
Auth file state
The local auth file is not updated with any OpenAI credential after the flow completes.
Current contents only show another provider entry, for example:
{ "minimax-cn-coding-plan": { "type": "api", "key": "REDACTED" } }Additional notes
localhost:1455is listening correctly during the flowPlugins
Internal auth plugins plus: - opencode-anthropic-auth@0.0.13 - usage-telemetry.ts The issue is specifically with OpenAI -> ChatGPT Pro/Plus browser auth.
OpenCode version
1.2.19
Steps to reproduce
opencode auth login.Token exchange failed: 403.Screenshot and/or share link
No response
Operating System
macOS 26.3.1
Terminal
Terminal.app