Fix Windows OAuth login: cmd /c start truncates auth URL at first & - #53
Open
MediaJohnD wants to merge 1 commit into
Open
Fix Windows OAuth login: cmd /c start truncates auth URL at first 5MediaJohnD wants to merge 1 commit into
MediaJohnD wants to merge 1 commit into
Conversation
cmd.exe's `start` re-parses its argument line and treats an unescaped `&` as a command separator, even when the URL is passed as its own array element to spawnSync. This silently truncated the OAuth authorize URL at the first `&` -- only `client_id=...` reached the browser, dropping redirect_uri and every param after it -- producing "The requested redirect uri is malformed or doesn't match client redirect URI" on every Windows login attempt. Escaping `&` as `^&` (cmd's own escape sequence) before the URL reaches `start` fixes it. macOS/Linux paths are untouched. Verified live: fresh `apollo auth login` on Windows now opens the full authorize URL, completes the OAuth flow, and `apollo auth whoami` correctly reports the logged-in user. Fixes apolloio#46 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
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.
Summary
auth loginfails with "redirect uri is malformed or doesn't match" — cmd /c start truncates the auth URL at the first & #46: on Windows,apollo auth loginfails with "The requested redirect uri is malformed or doesn't match client redirect URI"openBrowser()'s Windows branch passes the full OAuth authorize URL tocmd /c start.cmd.exe'sstartre-parses its argument line and treats an unescaped&as a command separator, even though the URL arrives as its ownspawnSyncarray element -- silently truncating the URL at the first&. Since the authorize URL is...?client_id=...&redirect_uri=...&response_type=...&scope=..., onlyclient_idever reaches the browser;redirect_uriand everything after it is dropped, so Apollo's OAuth server correctly rejects the (missing) redirect_uri.&as^&(cmd's own escape sequence) before handing the URL tostart, Windows-only. macOS (open) and Linux (xdg-open) paths are untouched since they don't share this parsing behavior.Test plan
npx tsc -p tsconfig.build.json-- clean build, no type errorsapollo auth loginnow opens the browser with the full, untruncated authorize URL, completes the OAuth flow end-to-end, andapollo auth whoamicorrectly reports the logged-in user afterwardauth loginfails with "redirect uri is malformed or doesn't match" — cmd /c start truncates the auth URL at the first & #46 without this fix (reverted locally to confirm before re-applying)🤖 Generated with Claude Code