anomalyco / anomalyco/opencode

OpenCode Desktop 1.18.20 – ChatGPT Plus OAuth fails with “Unexpected server error” and “Token exchange failed: 403”

Open
#43,850 4 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 21, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Dear OpenCode Team,

I am experiencing a persistent OpenAI / ChatGPT Plus OAuth authorization issue in OpenCode Desktop on Windows.

Environment:

OS: Windows 11 x64
OpenCode: Desktop application
OpenCode version: 1.18.20
Architecture: x64
Electron: 42.3.3
Node.js: 24.15.0

The issue happens when I try to connect OpenAI / ChatGPT Plus through the browser OAuth flow.

The browser-side authorization appears to complete successfully. The browser shows that OpenCode has been connected to ChatGPT successfully.

However, after returning to OpenCode Desktop, the UI displays:

授权失败:Unexpected server error. Check server logs for details.

In English:

Authorization failed: Unexpected server error. Check server logs for details.

I then checked the OpenCode server log. The actual backend error is:

Error: Token exchange failed: 403

I have seen this error repeatedly during multiple authorization attempts.

Example log entries:

2026-08-21T08:19:47.612Z
Error: Token exchange failed: 403

2026-08-21T08:20:35.364Z
Error: Token exchange failed: 403

2026-08-21T08:40:12.442Z
Error: Token exchange failed: 403

There was also another related error:

Error: Failed to initiate device authorization

In some previous attempts, I also encountered:

OAuth callback timeout - authorization took too long

The current problem can be reproduced as follows:

Open OpenCode Desktop.
Go to the OpenAI provider authentication page.
Choose ChatGPT Plus / Pro browser authorization.
Complete the login and authorization in the browser.
The browser reports that OpenCode has successfully connected to ChatGPT.
Return to OpenCode Desktop.
OpenCode displays:
Authorization failed: Unexpected server error. Check server logs for details.
The server log records:
Token exchange failed: 403

I have already tried the following:

Confirmed that OpenCode is already updated to the latest version, 1.18.20.
Restarted OpenCode completely.
Repeated the OAuth process several times.
Closed old browser authorization pages and started a fresh authorization attempt.
Reset the OpenCode authentication file:
C:\Users\43590.local\share\opencode\auth.json

to:

{}

and then retried authentication.

Enabled a global VPN.
Confirmed that browser-side ChatGPT authorization itself succeeds.

The issue still remains.

Relevant log paths on my machine:

C:\Users\43590.local\share\opencode\log\opencode.log

Desktop logs:

C:\Users\43590\AppData\Roaming\ai.opencode.desktop\logs

OpenCode configuration directory:

C:\Users\43590.config\opencode

My understanding of the failure is:

OpenCode starts OAuth
→ Browser login and authorization succeed
→ Authorization code is returned
→ OpenCode attempts to exchange the authorization code for tokens
→ Token endpoint returns HTTP 403
→ OpenCode Desktop shows “Unexpected server error”

Could you please help confirm whether this is a known issue in OpenCode Desktop 1.18.20 on Windows?

I would especially like to know:

Why the token exchange request returns HTTP 403 even though browser authorization succeeds.
Whether this is related to OpenCode Desktop proxy handling.
Whether OpenCode Desktop requires explicit HTTP_PROXY / HTTPS_PROXY settings even when the VPN is running in global mode.
Whether there is a known workaround for ChatGPT Plus / Pro OAuth.
Whether this is a current OpenCode OAuth bug or an OpenAI-side compatibility issue.

I can provide the complete opencode.log, desktop logs, and any other debugging information if needed.

Thank you for your help.

Best regards

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.