[BUG] Claude Code OAuth Authentication Fails - "OAuth account information not found in config"
Environment
- Claude Code version: 1.0.6
- Operating System: macOS
- Node.js version: v22.16.0
- npm version: 10.9.2
- Account type: Claude Max subscription
- Network environment: Corporate network with specific routing requirements
Description
Claude Code fails to complete OAuth authentication in my network environment, consistently showing the error:
OAuth error: Failed to fetch user roles: OAuth account information not found in config
Steps to Reproduce
- Install Claude Code:
npm install -g @anthropic-ai/claude-code - Run Claude Code:
claude - Select theme (any option)
- Select login method: "2. Claude app (requires Max subscription)"
- Browser opens OAuth page successfully
- Complete authorization (shows "You're all set up for Claude Code")
- Return to terminal
- Error appears:
OAuth error: Failed to fetch user roles: OAuth account information not found in config
Expected Behavior
After OAuth authorization, Claude Code should successfully authenticate and start normally.
Actual Behavior
Despite successful OAuth flow in browser, Claude Code fails to save or retrieve the authentication configuration, resulting in the error message. The browser shows "You're all set up" but the CLI cannot proceed.
Additional Context
- The OAuth flow completes successfully in browser
- Sometimes an authentication code is displayed to paste into Claude Code, but entering it doesn't resolve the issue
- The error suggests the OAuth account information is not being properly saved to the config file
- Message "Creating API key for Claude Code..." appears briefly before the error
Troubleshooting Attempted
- Complete uninstall and cleanup:
npm uninstall -g @anthropic-ai/claude-code rm -rf ~/.claude rm -rf ~/.npm-global/lib/node_modules/@anthropic-ai/ rm -rf ~/Library/Application\ Support/ClaudeCode npm cache clean --force - Tried both login methods (Claude app & Anthropic Console) - same error
- Tested with different browsers (Safari, Chrome)
- Fresh install on clean system
Possible Cause
The issue appears to be related to Claude Code's OAuth callback handling or configuration file creation/reading after successful browser authentication.
Related Issues
Similar authentication issues reported by other users with Max subscriptions, suggesting this might be a broader issue with the OAuth implementation.
Some things you can try:
- Remove ~/.claude.json, not just ~/.claude.
- Can you check if your network allows
https://api.anthropic.com? Claude Code makes a couple calls there for authentication. - Can you try downloading and logging in to a newer version (v1.0.11, for example)
Some things you can try:
- Remove ~/.claude.json, not just ~/.claude.
- Can you check if your network allows
https://api.anthropic.com? Claude Code makes a couple calls there for authentication.- Can you try downloading and logging in to a newer version (v1.0.11, for example)
Update: Even single character commands like 'h' or 'pwd' result in the same error: "API Error: Cannot convert argument to a ByteString because the character at index 0 has a value of 8217"
This happens with ANY input, suggesting a critical bug in Claude Code's character encoding handling.
Environment details:
- macOS Terminal works fine (echo "test" works)
- Using API key authentication (Max member OAuth also failed)
- Error persists after removing all config files
- Version: [run claude --version to check]
There seems to be a different error here related to your input.
The character at index 0 with value 8217 is a right single quotation mark (' - Unicode U+2019). This is a "smart quote" or "curly quote" that's commonly inserted by word processors, rich text editors, or when copying text from formatted documents.
Can you share a screenshot of the API Error and also the result of /status?
Here's the screenshot showing both the API error and /status result:
Key observations:
- Error occurs when typing single character 'h'
- Claude Code Status: v1.0.11
- Auth Token: none (using API Key authentication instead)
- API Key: ANTHROPIC_API_KEY (environment variable)
- Model: claude-sonnet-4-20250514
- Working Directory: /Users/moment
The error happens with ANY input, suggesting the issue is in Claude Code's input handling before it reaches the API.
Ok I think there's something wrong with how the OAuth was saved. Can you try:
-
security delete-generic-password -a $USER -s "Claude Code-credentials" - Run
/loginagain.
If that still doesn't work, I don't have many remaining ideas...
Thank you for the suggestion! It helped uncover the root cause:
What I discovered:
-
security delete-generic-passwordreturned "item could not be found" - meaning OAuth credentials were never saved to keychain - This explains why authentication never persists
Testing OAuth flow:
- OAuth browser flow completes successfully
- But Claude Code fails with: "Failed to fetch user roles: Request failed with status code 403"
- Since user roles can't be fetched, credentials are never saved to keychain
- This creates the authentication loop
Two separate bugs identified:
- OAuth Bug: 403 error when fetching user roles (prevents Max subscription login)
- Input Bug: ByteString encoding error with ANY input after authentication fails
The OAuth credentials not being in keychain is a symptom, not the cause - they can't be saved because the user role fetch fails with 403.
Environment: macOS, Max subscription, v1.0.11
You may be running into the following issue: https://www.anthropic.com/supported-countries
Thanks for your patience in debugging this with me.
Actually, based on the fact that you see "fetching user roles", you are likely going through the "Anthropic Console account" flow instead of the "Claude account with subscription" flow. Ensure that you are selecting "Claude account with subscription" if you want to use your Claude Max plan.
Fixed my issue. Thx
Sorry to reopen the issue but I am getting this right now, maybe related to the outage that you guys had today:
claude -p hi
API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid OAuth token. The provided token was not found or is malformed."}}
I am trying to use my claude code account. I've already removed the .claude files, reinstalled the npm package and logged out & back in, same deal.
Any ideas?
Must be an outage. I just encountered the same.
Same
Same here, time to hit the hay
Same
same
Hopping on the "same" bandwagon
same me too
same :)
Same
Same
Same
Same
seems to be working for me now
When your dealers phone stops working
lmaoooo all bros here
time to hit the gym
same here. I thought it was because I installed both the local and global versions of Claude Code by mistake, but it seems to be a bug.
same issue here
I'm having the same issue with the exact same error message. Haven't logged in for a week... Definitely on Anthropic's side.
same issue.