You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OAuth Authorization Fails with HTTP 400 in OpenCode Desktop 2.0.28 on Windows #55211
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
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.
Reacted by Tim Wood, Steven Prins, Ricardo Romero, Jaap de Heer, John and Agustin
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).
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.
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."
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.
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:
Proxy/VPN on the Windows Desktop report. This host had a live loopback listener and still got the 400 from the token endpoint.
Legacy Codex browser login is a different method (chatgpt-browser, client app_EMoamEEZ73f0CkXaXp7hrann, /oauth/token). It is not evidence that token-sharing exchange is healthy.
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.
I actually discovered that it's possible I was getting this issue because my subscription downgraded to free version. I'm yet to resubscribe but I'm pretty sure it'll fix the issue in my case
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
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).
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.
Activity
opencode-agent commentedon Oct 13, 2026
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:
GWGWSEUI commentedon Oct 13, 2026
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.
jaapdeheer commentedon Oct 20, 2026
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 freshopencode auth login openaiwith "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.
yookibooki commentedon Oct 21, 2026
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.
chubi-x commentedon Oct 21, 2026
Im also experiencing this failure. v2.1.1 on linux x64
v44r commentedon Oct 23, 2026
Error persists in v2.1.3.
JMoCoder commentedon Oct 24, 2026
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/callbacknever reached the server. For the reproduction below, the callback was delivered with a local request to a listener that was still bound on127.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_clientandredirect_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:
codeandclient_id. A state mismatch or a missing code is a different error ("Invalid OAuth state" / "Missing authorization code"). We did not get those.client_id = saved ?? callback client_id, the sameredirect_uri,code_verifier, andresource=https://api.openai.com/v1. So this 400 is not "the token request still sentdynamic_agent_client".Request failed: ${status}and discards the body. That is why 2.1.4 logs still cannot showinvalid_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.oaiapp_…id is written only after a successful token response. After this 400, a new attempt still starts atdynamic_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 newoaiapp_…ids, but without the discarded body it is not proven to be the cause of this particular 400.Ruled out for this reproduction:
api.responses.writeafter a successful Codex login) and ChatGPT token sharing: changing reasoning effort causes HTTP 400 and breaks session continuation #54075 (400subscription_sharing_unsupported_capabilityafter login, when changing reasoning effort). Both require a stored credential. None was stored here.chatgpt-browser, clientapp_EMoamEEZ73f0CkXaXp7hrann,/oauth/token). It is not evidence that token-sharing exchange is healthy.Useful logging change, without guessing the OpenAI error: include the token endpoint's JSON
erroranderror_descriptionin the attempt message and the server log, and do not persist secrets. #56782 is the same gap for 400/429 on re-auth.chubi-x commentedon Oct 25, 2026
jaapdeheer commentedon Oct 25, 2026
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).
krabishe commentedon Oct 29, 2026
After updating OpenCode Desktop to 2.2.1 on Windows, every prompt in an existing session started failing with:
The affected connection used the OpenAI provider with ChatGPT OAuth (
chatgpt-token-sharing). The selected model wasopenai/gpt-6.1-terra, variantmax.The local server log recorded the error during connection authorization and model preparation:
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.