[BUG] Spacing in URL leads to Firefox error "Invalid OAuth Request Unknown scope: user:"
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
This is something that worked as recently as last week. When I try to use /login with claude code running in a remote session over ssh, I get the authentication URL (as normal), but there are newlines/spaces between lines. When I copy/paste this url with \n and spaces into firefox, firefox gives an error:
"Invalid OAuth Request
Unknown scope: user:"
This is "fixable" one of two ways: 1) using chrome, which seems more tolerant of the spacing/newlines or 2) pasting the url into an editor and manually removing the spacing/newlines that result.
I don't think this is my environment (but it certainly could be). But it seems like the call to print should not attempt to "prettify" the url output, and just print it as-is so we can copy/paste it. It probably works better if it's not remote with a clickable link or something.
I looked for this exact error string and haven't found it in the tickets, but I wouldn't be surprised if this was a dupe (sorry).
What Should Happen?
You should be able to copy/paste the link from claude code cli when you run /login, and paste it into any browser and have it work.
Error Messages/Logs
Error output (firefox): Invalid OAuth Request
Unknown scope: user:
Example URL (without modification):
https://claude.ai/oauth/authorize?code=true&client_id=REDACTED&response_type=code&redirect_uri=https%3A%2F%2Fplatform.claude.com%2Foauth%2Fcode%2Fcallback&scope=org%3Acreate_api_key+user%3A
profile+user%3Ainference+user%3Asessions%3Aclaude_code+user%3Amcp_servers+user%3Afile_upload&code_challenge=REDACTED&code_challenge_method=S256&state=REDACTED_PARTIALLY_TaSsHO
sTbDVyN30q0
In this copied version, you can see the weird spacing and newlines that cause the problem.
Steps to Reproduce
Open claude code on a remote machine (e.g., over ssh). Type /login. When the URL is provided, copy/paste the whole thing without modification into firefox. You should (might?) encounter the issue.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
No idea.
Claude Code Version
2.1.76 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗