feat(login): headless OAuth via --no-browser / --callback-url - #198
Draft
tonychang04 wants to merge 1 commit into
Draft
feat(login): headless OAuth via --no-browser / --callback-url#198tonychang04 wants to merge 1 commit into
tonychang04 wants to merge 1 commit into
Conversation
In sandboxed environments (ChatGPT app, SSH, containers) the browser can never reach the CLI's loopback callback server, so browser login hangs forever. Split the flow into two invocations: - login --no-browser: prints the authorize URL and persists PKCE verifier/state to ~/.insforge/pending-login.json (0600, 10-min TTL matching the server's authorization-code expiry), then exits. - login --callback-url <url>: accepts the full redirect URL copied from the browser address bar (the 127.0.0.1 page shows a connection error but the code/state survive in the URL), verifies state, exchanges the code with the persisted verifier, and stores credentials. The default browser flow is unchanged; its non-TTY output now hints at the fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcszudKMZBSm5RMP14h7fu
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This was referenced Jul 16, 2026
timothybrush
pushed a commit
to timothybrush/insforge-skills
that referenced
this pull request
Jul 16, 2026
…-url) Companion to InsForge/CLI#198. In sandboxes like the ChatGPT app the browser cannot reach the CLI's loopback callback, so browser login hangs; the new two-step flow prints the auth URL, the user pastes back the redirect URL, and the CLI redeems it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcszudKMZBSm5RMP14h7fu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When the CLI runs inside a sandbox (ChatGPT app plugin, SSH, containers),
insforge loginopens the browser on the host, but the OAuth redirect goes to a loopback listener inside the sandbox that the host browser can never reach — login hangs until timeout. Seen live driving the InsForge plugin from the ChatGPT app (npx @insforge/cli@latest orgs list --json→ auth URL → browser dead-ends onhttp://127.0.0.1:38961/callback?...).What
Two-step headless flow, following the gcloud
--no-launch-browserpattern (no backend changes needed):insforge login --no-browser— prints the authorize URL, persists PKCE verifier/state/redirect_uri to~/.insforge/pending-login.json(0600, 10-min TTL matching the server's code expiry), exits.127.0.0.1redirect (expected — instructions say so) with code+state in the address bar.insforge login --callback-url "<pasted url>"— parses code/state (tolerates quotes/whitespace, bare query strings; surfaceserror=params), verifies state, exchanges the code with the persisted verifier, stores credentials, deletes the pending file.Default browser flow unchanged; its non-TTY output now hints at the fallback. Telemetry
methoddistinguishesoauth_no_browser/oauth_callback_url.Verification
--no-browserwrites pending state + prints URL (human &--jsonmodes); wrong state → local error; correct state + fake code reaches the real token endpoint and getsinvalid_grant— full exchange wiring accepted server-side.Notes
skills/insforge-cli/references/login.md) — will link.🤖 Generated with Claude Code
https://claude.ai/code/session_01GcszudKMZBSm5RMP14h7fu
Summary by cubic
Adds a headless OAuth login flow to the CLI with
--no-browserand--callback-urlso login works in sandboxes/SSH where loopback callbacks fail. Default browser login is unchanged; non-TTY mode now suggests the fallback.insforge login --no-browser: prints the auth URL and saves pending PKCE/state/redirect_uri to~/.insforge/pending-login.json(0600, 10‑min TTL).insforge login --callback-url "<url>": parses code/state (tolerates quotes/whitespace or bare query strings), surfaces provider errors, verifies state/expiry, exchanges the code, stores credentials, and clears the pending file.oauth_no_browserandoauth_callback_urlmethods.--no-browserif the callback can’t reach the process.Written for commit 03f9a07. Summary will update on new commits.
Note
Add headless OAuth login via
--no-browserand--callback-urlflags--no-browsergenerates PKCE/state, persists a pending login file, and prints an authorize URL with instructions instead of starting a local callback server.--callback-url <url>completes a pending headless login by parsing the pasted callback URL, verifying state, exchanging the auth code, and storing credentials; enforces a 10-minute TTL on the pending login.PENDING_LOGIN_FILEin the global config directory with 0600 permissions via new helpers in config.ts.performOAuthLoginnow prints extra stderr guidance suggesting the--no-browserflow when the browser cannot reach the machine.methodvalues now includeoauth_no_browserandoauth_callback_urlin addition to existing values.Macroscope summarized 03f9a07.