Skip to content

OAuth Authorization Fails with HTTP 400 in OpenCode Desktop 2.0.28 on Windows #55211

Closed

Description

@GWGWSEUI

Description

OpenCode Desktop 2.0.28 fails to complete ChatGPT OAuth authorization on Windows. After selecting the ChatGPT sign-in option and proceeding through the browser authorization flow, the browser displays Authorization failed with the message OpenCode couldn't finish connecting to ChatGPT. Request failed: 400.

The issue persists after updating OpenCode to version 2.0.28. All Windows proxy settings are disabled, and no obvious VPN or proxy processes were found.

The available logs do not identify the root cause. Please investigate why the OAuth flow returns HTTP 400 and provide more detailed diagnostic information so the underlying failure can be identified.

Plugins

No relevant third-party plugins identified. The issue occurs during ChatGPT OAuth authorization, before a successful connection is established. (No complete plugin inventory has been verified.)

OpenCode version

OpenCode Desktop 2.0.28.

Steps to reproduce

Steps to reproduce

Open OpenCode Desktop on Windows.

Select the option to sign in or connect with ChatGPT.

Continue through the browser-based OAuth authorization flow.

Observe the error page.

Actual result:

Authorization failed

OpenCode couldn't finish connecting to ChatGPT.

Request failed: 400

The same failure occurred before and after updating OpenCode to version 2.0.28.

Screenshot and/or share link

Image

Operating System

Windows 10

Terminal

Not applicable to the primary reproduction steps. The issue occurs in OpenCode Desktop during browser-based OAuth authorization, rather than during a terminal command.

Activity

  1. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I couldn't reproduce this here because it needs a real ChatGPT account (and ideally Windows with OpenCode Desktop), which this environment doesn't have.

    From the code, "Request failed: 400" comes from the last step of "Sign in with ChatGPT". After you approve in the browser, OpenCode exchanges the code for tokens, and ChatGPT's server is rejecting that request. Right now OpenCode only shows the status code and drops ChatGPT's error details, which is why your logs don't show the cause. That code hasn't changed between 2.0.28 and the latest dev.

    A maintainer with a ChatGPT account will need to look into it. In the meantime, these would help:

    • Have you signed in with ChatGPT in OpenCode before, on this machine or account? Does it still fail after removing any existing OpenAI/ChatGPT connection in OpenCode and trying again?
    • Does the legacy "Codex browser" sign-in method under OpenAI work?
    • Which ChatGPT plan you're on (Plus, Pro, Team/Business, Enterprise).
  2. GWGWSEUI commented on Oct 13, 2026

    @GWGWSEUI
    Author

    My ChatGPT account is on the Free plan. The legacy "Codex browser" sign-in method under OpenAI works successfully, but the regular "Sign in with ChatGPT" flow fails with HTTP 400 after I approve authorization in the browser.

  3. jaapdeheer commented on Oct 20, 2026

    @jaapdeheer

    Same here, on macOS with the CLI (2.0.26), ChatGPT Plus plan.

    In my case it worked fine first. The log shows the OpenAI credential refreshing successfully at 11:34 and 12:46 UTC today, and it was working fine. After a few hours idle (afk), every message now fails with Request failed: 400. A fresh opencode auth login openai with "Sign in with ChatGPT" fails the same way as @GWGWSEUI's screenshot above.

    The legacy Codex login does work for me, but it doesn't really help: both gpt-6.1-sol and gpt-6-astra are rejected with "The '...' model is not supported when using Codex with a ChatGPT account."

    Other providers (e.g. Anthropic) still work fine.

  4. yookibooki commented on Oct 21, 2026

    @yookibooki

    I’m experiencing the same ChatGPT sign-in failure: after authorization, OpenCode shows “Authorization failed” and “Request failed: 400.” It happens consistently.

    Environment: OpenCode v2.1.1 on Linux x64, using tmux and Bash.

  5. chubi-x commented on Oct 21, 2026

    @chubi-x

    Im also experiencing this failure. v2.1.1 on linux x64

  6. v44r commented on Oct 23, 2026

    @v44r

    Error persists in v2.1.3.

  7. JMoCoder commented on Oct 24, 2026

    @JMoCoder

    Reproduced on Linux x64 with OpenCode 2.1.4 (headless server, not Desktop, not Windows). Same failure as the screenshot: after browser approval, the local callback page is "Authorization failed" and the attempt status is failed / Request failed: 400. No OpenAI connection is stored.

    This is not the loopback "connection refused" problem. The browser was on another machine, so the first redirect to 127.0.0.1:<port>/auth/callback never reached the server. For the reproduction below, the callback was delivered with a local request to a listener that was still bound on 127.0.0.1. OpenCode accepted that callback (state matched; the response was its own 400 HTML page, not a refused TCP connection) and then failed while exchanging the code.

    Method: chatgpt-token-sharing ("Sign in with ChatGPT").
    Token endpoint: POST https://auth.openai.com/api/accounts/oauth/token.
    Authorize URL used client_id=dynamic_agent_client and redirect_uri=http://127.0.0.1:<ephemeral>/auth/callback.
    The callback included an issued oaiapp_… client id. There was no existing OpenAI connection.

    Installed 2.1.4 behavior, from the binary:

    • The callback handler reads code and client_id. A state mismatch or a missing code is a different error ("Invalid OAuth state" / "Missing authorization code"). We did not get those.
    • If a saved client id exists and the callback client id differs, the attempt fails with "ChatGPT returned a different client than this connection." We did not get that either, which matches "no saved connection".
    • Otherwise it exchanges with client_id = saved ?? callback client_id, the same redirect_uri, code_verifier, and resource=https://api.openai.com/v1. So this 400 is not "the token request still sent dynamic_agent_client".
    • On any non-2xx token response, the client throws Request failed: ${status} and discards the body. That is why 2.1.4 logs still cannot show invalid_grant / invalid_client / error_description. This matches the 2026-10-13 note that the detail is dropped, and it is still true one release after the 2.1.3 report.
    • The issued oaiapp_… id is written only after a successful token response. After this 400, a new attempt still starts at dynamic_agent_client. OpenAI's token-sharing guide says a failed exchange should be retried with the issued client id retained, not by starting another dynamic registration. 2.1.4 does not do that. That can explain a loop of new oaiapp_… ids, but without the discarded body it is not proven to be the cause of this particular 400.

    Ruled out for this reproduction:

    Useful logging change, without guessing the OpenAI error: include the token endpoint's JSON error and error_description in the attempt message and the server log, and do not persist secrets. #56782 is the same gap for 400/429 on re-auth.

  8. chubi-x commented on Oct 25, 2026

    @chubi-x
  9. jaapdeheer commented on Oct 25, 2026

    @jaapdeheer

    9. I actually discovered that it's possible I was getting this issue because my subscription downgraded to free version.

    Same here 🤦
    Not 100% sure the downgrade and the 400s were at the same time, but it seems likely. After resubscribing to a paid ChatGPT plan, it works again.

    Still, if possible, a clearer error would be very useful. Especially since OpenAI doesn't seem to send any kind of notification saying your subscription just ended (which is quite possibly days/weeks/months after you canceled renewal).

  10. krabishe commented on Oct 29, 2026

    @krabishe

    After updating OpenCode Desktop to 2.2.1 on Windows, every prompt in an existing session started failing with:

    Request failed: 400
    

    The affected connection used the OpenAI provider with ChatGPT OAuth (chatgpt-token-sharing). The selected model was openai/gpt-6.1-terra, variant max.

    The local server log recorded the error during connection authorization and model preparation:

    Integration.Authorization: Request failed: 400
    Integration.connection.resolve → ModelResolver.prepare
    

    This appears to happen before the model request is sent. The log did not include the response body or a more specific error code, so I can’t tell whether the cause was token refresh, an upstream response, or a regression in OpenCode.

    Workaround: Reconnecting the OpenAI account in OpenCode resolved the issue, and prompts work again.

    The same model had worked before the update. The timing suggests a possible connection to the update, but it does not establish causation. It would be helpful if OpenCode could surface a safe, more specific authorization error and prompt the user to reconnect when appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions