Skip to content

fix: CLI-style auth — open URL, then paste Studio key - #8

Merged
sdziupin merged 1 commit into
mainfrom
feat/cli-auth-paste-key-36eb
Aug 9, 2026
Merged

sdziupin merged 1 commit into
mainfrom
feat/cli-auth-paste-key-36eb

Conversation

@sdziupin

@sdziupin sdziupin commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Problem

  1. Opening the Command Code Studio auth link could fail with Something went wrong / API error: 403.
  2. v0.3.0 added a standalone Enter Command Code API key method — that was the wrong UX. The key is part of the cmd login flow: after Authorize, Studio shows a one-time key to paste into the terminal.

Fix

  • Switch Go-plan login to OpenCode method: "code" (same pattern as Claude plugin): show Studio URL, then prompt to paste the key (or ok if the localhost callback already succeeded).
  • Remove the standalone API-key auth method.
  • Keep the localhost callback server (same URL as cmd login) and harden CORS for Chrome Private Network Access (Access-Control-Allow-Private-Network) so automatic transfer can still succeed when the browser can reach the callback.
  • Prefer a key already POSTed to localhost; otherwise validate the pasted Studio key via /alpha/whoami.

Notes on the 403

Studio’s error page (/studio/auth/cli/error) is shown when the Authorize action itself fails (not when the localhost callback returns 403 — that path shows the Copy your API key fallback). Callback CORS was still tightened because a rejected localhost POST previously left method: "auto" waiting forever with no paste prompt.

Test plan

  • npm run build
  • npm test (smoke includes PNA preflight, Studio POST → paste ok, and asserts no standalone API-key method)
  • Manually: opencode auth login --provider command-code → Login with Command Code → Authorize → paste key
Open in Web Open in Cursor 

Match `cmd login`: OAuth uses method "code" so OpenCode prompts for the
key Studio shows after Authorize (or "ok" if localhost callback already
succeeded). Remove the standalone "Enter API key" method. Harden the
localhost callback CORS for Chrome Private Network Access.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
@sdziupin
sdziupin marked this pull request as ready for review August 9, 2026 06:09
@sdziupin
sdziupin merged commit 8ba878d into main Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant