Skip to content

opencode connect OpenAI fails!!! #7992

Closed as not planned
Closed as not planned

Description

@gaoxiangyu369

Question

opencode connect OpenAI, the OpenAI page said authorization successful, but opencode still Waiting for authorization

Image Image

Activity

  1. github-actions commented on Jan 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. risingjerry commented on Jan 15, 2026

    @risingjerry

    Question

    opencode connect OpenAI, the OpenAI page said authorization successful, but opencode still Waiting for authorizationopencode 连接 OpenAI,OpenAI 页面显示授权成功,但 opencode 仍显示等待授权

    Image Image

    hey bro ,have you alrady solve this problem?

  3. muuufc commented on Jan 15, 2026

    @muuufc

    I have the same issue

  4. risingjerry commented on Jan 15, 2026

    @risingjerry

    I have the same issue

    I managed to resolve this by enabling TUN mode on my VPN client.

    It appears the CLI/Server requires a network-level proxy to correctly handle the OAuth callback.

    Works perfectly now!

  5. muuufc commented on Jan 15, 2026

    @muuufc

    I have the same issue

    I managed to resolve this by enabling TUN mode on my VPN client.

    It appears the CLI/Server requires a network-level proxy to correctly handle the OAuth callback.

    Works perfectly now!

    Thanks for the tip, didn't work for me unfortunately. Tried with vpn off as well and same issue

  6. PerrinYong commented on Jan 23, 2026

    @PerrinYong

    我这边解决了
    通过以下方式启动opencode:

    set HTTPS_PROXY=http://127.0.0.1:7890
    set HTTP_PROXY=http://127.0.0.1:7890
    set NO_PROXY=localhost,127.0.0.1,::1
    
    opencode.exe

    原因是OpenCode 去请求 OpenAI 的 OAuth token 端点时,被返回了 403 Forbidden.
    浏览器那边登录成功(浏览器吃系统代理)
    OpenCode server 进程这边 exchange token 没走系统代理

  7. andyWang1688 commented on Jan 24, 2026

    @andyWang1688
    Contributor

    我这边解决了 通过以下方式启动opencode:

    set HTTPS_PROXY=http://127.0.0.1:7890
    set HTTP_PROXY=http://127.0.0.1:7890
    set NO_PROXY=localhost,127.0.0.1,::1

    opencode.exe

    原因是OpenCode 去请求 OpenAI 的 OAuth token 端点时,被返回了 403 Forbidden. 浏览器那边登录成功(浏览器吃系统代理) OpenCode server 进程这边 exchange token 没走系统代理

    但是这样登录后也用不了模型啊

  8. R44VC0RP commented on Jan 24, 2026

    @R44VC0RP
    Collaborator

    @fwang can you follow up on this?

  9. wuxiaohui0 commented on Jan 26, 2026

    @wuxiaohui0

    我的论文解决了通过以下方式启动opencode:
    设置 HTTPS_PROXY= http://127.0.0.1:7890
    设置 HTTP_PROXY= http://127.0.0.1:7890
    设置 NO_PROXY=localhost,127.0.0.1,::1
    opencode.exe
    原因是OpenCode去请求OpenAI的OAuth token端点时,被返回了403 Forbidden。 浏览器侧面登录成功(浏览器吃系统代理) OpenCode server 进程队列交换令牌没走系统代理

    但是这样登录后也用不了模型啊

    Have you solved this problem? Could you please share your solution?

  10. andyWang1688 commented on Jan 26, 2026

    @andyWang1688
    Contributor

    我的论文解决了通过以下方式启动opencode:
    设置 HTTPS_PROXY= http://127.0.0.1:7890
    设置 HTTP_PROXY= http://127.0.0.1:7890
    设置 NO_PROXY=localhost,127.0.0.1,::1
    opencode.exe
    原因是OpenCode去请求OpenAI的OAuth token端点时,被返回了403 Forbidden。 浏览器侧面登录成功(浏览器吃系统代理) OpenCode server 进程队列交换令牌没走系统代理

    但是这样登录后也用不了模型啊

    Have you solved this problem? Could you please share your solution?

    Please refer to the documentation at https://opencode.ai/docs/network/ — it explains how to set up a proxy for OpenCode. The core issue is that OpenCode cannot reach your proxy, so you’ll need to manually configure some environment variables to resolve this.

  11. Nick-Hopps commented on Feb 3, 2026

    @Nick-Hopps

    我这边解决了 通过以下方式启动opencode:
    set HTTPS_PROXY=http://127.0.0.1:7890
    set HTTP_PROXY=http://127.0.0.1:7890
    set NO_PROXY=localhost,127.0.0.1,::1
    opencode.exe
    原因是OpenCode 去请求 OpenAI 的 OAuth token 端点时,被返回了 403 Forbidden. 浏览器那边登录成功(浏览器吃系统代理) OpenCode server 进程这边 exchange token 没走系统代理

    但是这样登录后也用不了模型啊

    同样的问题按照这个方法开启tun模式成功解决

    我也有同样的问题。

    我通过在 VPN 客户端上启用 TUN 模式解决了这个问题。
    看来 CLI/服务器需要网络级代理才能正确处理 OAuth 回调。
    现在一切正常!

    我这边开 TUN 没用,设置代理可行=。=

  12. chrishowell commented on Feb 4, 2026

    @chrishowell

    NODE_TLS_REJECT_UNAUTHORIZED=0 opencode auth login 🥳
    (obviously be careful who's MitM'ing you)

  13. DoraemonHugU commented on Mar 14, 2026

    @DoraemonHugU

    I encountered this problem a long time ago.
    I was using Windows 11 + WSL, and I was using OpenCoder on Windows at the time.
    OpenAI's login callback port is 1415 (this is the case for me).
    Solution:

    1. I disabled WSL. That solved the problem. (It seems like a port conflict was the issue.)
  14. fmolinam commented on Apr 16, 2026

    @fmolinam

    dummy

  15. mwisselaar commented on May 24, 2026

    @mwisselaar

    If you're running opencode on a remote/headless server (e.g. a VM in Proxmox), neither the browser method nor the headless method may work out of the box. The browser method fails because there's no browser on the server, and the headless/device code flow requires a ChatGPT Enterprise or Edu workspace.

    Solution: SSH port forwarding

    This only applies to remote installs. If opencode is running on your local machine, just use the browser method normally.

    Step 1 — On your local machine, open a terminal and create an SSH tunnel:

    ssh -L 1415:localhost:1415 user@your-server-ip

    Keep this window open.

    Step 2 — In that same SSH session (you're now on the server), start the auth flow:

    opencode auth login

    Select ChatGPT Pro/Plus (browser). Opencode will output a URL.

    Step 3 — Copy that URL and open it in the browser on your local machine. Log in with OpenAI.

    Step 4 — OpenAI sends the callback to localhost:1415 on your local machine. The tunnel forwards it to the server automatically. Opencode receives it and authentication completes.

    The token is saved on the server, so you only need to do this once. After that, opencode starts normally without the tunnel.

  16. rekram1-node commented on Jun 23, 2026

    @rekram1-node
    Contributor

    Automated: closing question issues.

    GitHub Issues are for bug reports and feature requests only — questions / support are no longer tracked here.

    If this is a bug or feature request, please open a new issue with the appropriate template.

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

Metadata

Metadata

Assignees

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