[BUG] OAuth login fails with status code 400 in VS Code and "Invalid code" in CLI on macOS
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?
OAuth authentication fails in both the official Claude Code VS Code extension and Claude Code CLI on macOS.
In the VS Code extension, selecting "Claude.ai Subscription" immediately shows:
Request failed with status code 400
I also tested authentication using Claude Code CLI.
The CLI successfully generates the OAuth authorization URL and displays:
Paste code here if prompted >
I open the generated authorization URL in a browser, complete authentication, copy the full authorization code, and paste it back into the same CLI OAuth session.
Claude Code then returns:
OAuth error: Invalid code. Please make sure the full code was copied
I retried with newly generated OAuth sessions and fresh authorization codes, but the same error occurs.
I also checked for ANTHROPIC_ and CLAUDE_ environment variables using:
env | grep -E 'ANTHROPIC|CLAUDE'
No matching environment variables are set.
What Should Happen?
OAuth authentication should complete successfully after authorizing the Claude.ai account.
The VS Code extension should log in without returning HTTP 400, and the CLI should accept the authorization code generated for the same OAuth session.
Error Messages/Logs
Steps to Reproduce
- Install/open the official Claude Code extension in VS Code on macOS.
- Open Claude Code.
- Select "Claude.ai Subscription".
- Observe: "Request failed with status code 400".
- Open Terminal.
- Run
claude. - Start the Claude.ai OAuth login flow.
- Copy the OAuth URL generated by Claude Code.
- Open the URL in a browser and complete authorization.
- Copy the full authorization code.
- Paste the code into the same CLI session at "Paste code here if prompted >".
- Press Enter.
- Observe: "OAuth error: Invalid code. Please make sure the full code was copied".
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.283
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_