opencode icon indicating copy to clipboard operation
opencode copied to clipboard

openai: adding a second ChatGPT account fails with workspace scope denied

Open KomeijiReimu opened this issue 1 month ago • 6 comments

Description

Adding another account with “Sign in with ChatGPT” fails on the OpenAI authorization page with 3p_login_workspace_scope_denied: the app is only available to members of its workspace. Removing the first saved account and then signing in with the second succeeds. Keeping one account on the new method and adding the other through “Codex browser (legacy)” also works.

In v2.0.32, the ChatGPT OAuth method takes the client ID from the active credential, including when the TUI starts “Add account”. OpenAI’s account-management guide says a different account should use its own saved registration or register a new one with client_id=dynamic_agent_client: https://developers.openai.com/siwc/token-sharing-open-source/profiles-and-sessions#switching-chatgpt-accounts

Expected: adding the second account should leave the first account connected and start an independent registration. Reauthorizing an existing account should retain that account’s issued client ID.

Plugins

@cortexkit/opencode-magic-context@latest, @cortexkit/[email protected], oh-my-opencode-slim. Not yet reproduced with plugins disabled.

OpenCode version

2.0.32

Steps to reproduce

  1. Run /connect, select OpenAI, then “Sign in with ChatGPT”, and sign in with account A.
  2. Run /connect again, select OpenAI → “Add account” → “Sign in with ChatGPT”.
  3. Sign in with a different ChatGPT account B.
  4. Observe the workspace-scope denial. Remove A from OpenCode and repeat B’s sign-in; it succeeds.

Screenshot and/or share link

Not available.

Operating System

Linux x86_64 / WSL2, kernel 6.18.54.1-microsoft-standard-WSL2

Terminal

tmux (TERM=tmux-256color), zsh

KomeijiReimu avatar Oct 17 '26 03:10 KomeijiReimu

Thanks for the detailed report. I couldn't reproduce this here: the denial comes from OpenAI's live sign-in page, and testing it needs two real ChatGPT accounts in different workspaces, which this sandbox doesn't have. A maintainer with such accounts will need to confirm it.

Your explanation matches the code, though I haven't run it. In packages/core/src/plugin/provider/chatgpt.ts, "Sign in with ChatGPT" takes its client ID from the active OpenAI credential and puts it in the authorize URL. It only falls back to dynamic_agent_client when no ID is saved. Nothing treats "Add account" differently from signing in again to an existing account, so account B's sign-in reuses account A's client ID. That code is the same in 2.0.32 and on dev.

Until this is looked at, the workaround you found still works: connect the second account through "Codex browser (legacy)".

Related: #52141 and #52147, the PRs that added this sign-in method.

opencode-agent[bot] avatar Oct 17 '26 03:10 opencode-agent[bot]

I'm experiencing the same issue on OpenCode 2.2.7 on macOS.

The first ChatGPT account connects successfully, but adding a different account via “Sign in with ChatGPT” fails with:

3p_login_workspace_scope_denied

Adding the second account via “Codex browser (legacy)” succeeds.

iCodePoet avatar Nov 12 '26 10:11 iCodePoet

@iCodePoet so whats the diff with #56302

KomeijiReimu avatar Nov 12 '26 11:11 KomeijiReimu

@KomeijiReimu The core fix overlaps with #56302. The additional changes in #63517 cover reauthorization of a selected account in the web/desktop app, along with an E2E regression test. Feel free to use the app-related changes if they’re useful for your PR.

iCodePoet avatar Nov 12 '26 11:11 iCodePoet

same issue being experienced

xeonise avatar Nov 18 '26 17:11 xeonise

My fix for this issue (#56302) was closed by the automated PR cleanup. Could a maintainer reopen it so the fix can be reviewed? I’ve also left a reopen request on the PR. Thanks! @rekram1-node @thdxr

KomeijiReimu avatar Nov 21 '26 06:11 KomeijiReimu