Claude Code does not handle new OAuth after archiving workspace
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version:
v0.3.6<!-- 使用claude --version获取最新的实际版本号 --> - Operating System: macOS 14.3
- Terminal: Terminal App (zsh)
Bug Description
I've successfully completed OAuth authentication for Claude Code CLI, and the Anthropic website confirmed my setup with the message:
"You’re all set up for Claude Code. You can now close this window."
However, when I attempt to use the Claude Code CLI (claude), it immediately returns the following error:
API Error: 403 {"error":{"type":"forbidden","message":"Request not allowed"}}
My Anthropic console shows newly generated API keys in the Claude Code workspace, but the CLI still cannot authenticate successfully.
Steps to Reproduce
- Install Claude Code CLI globally via npm (
npm install -g @anthropic-ai/claude-code) - Run the OAuth authentication (
claude auth login) - Complete OAuth successfully (confirmed by webpage)
- Run
claudecommand in the terminal - Encounter the 403 forbidden error above.
Expected Behavior
Claude Code CLI should authenticate successfully after OAuth, and I should be able to interact normally with the CLI.
Actual Behavior
Claude Code CLI immediately returns a 403 forbidden error ("Request not allowed") every time it is launched.
Additional Context
- My Anthropic account billing is active, with sufficient funds.
- Network proxy and connectivity have been verified as working correctly.
- My Anthropic account email is
bobbyding.dy@gmail.com.
Additionally, I observed unexpected behavior in the Anthropic API key management page:
- The API keys associated with Claude Code workspace never show as successfully created (they remain stuck in a pending state without workspace details).
- When attempting to delete these seemingly unsuccessful keys, I consistently receive a
"Not found"error, and the keys remain undeleted.
This might indicate a backend issue on Anthropic’s side causing the keys to remain unrecognized or improperly provisioned.
Screenshots:
- API keys stuck without workspace information:
<img width="969" alt="Image" src="https://github.com/user-attachments/assets/f27f1c38-321b-4e0a-9e68-c8565382250b" />
- Error (
"Not found") when attempting to delete these keys:
<img width="972" alt="Image" src="https://github.com/user-attachments/assets/bef9f4bf-b17a-49ed-b3d4-f9dd3df6f096" />
---
15 Comments
UPDATE (Potential Root Cause Identified)
I believe I have identified the root cause of this issue:
When Claude Code CLI first completed the OAuth authentication, it automatically created a default workspace for storing API keys. However, I mistakenly archived this default workspace. As a result, subsequent OAuth attempts cannot successfully create or associate new API keys.
This explains why the newly created keys remain stuck without workspace details and why attempting to delete these keys results in a "Not found" error.
Sorry why close this issue ?
seems like this was an issue with auth against a closed workspace? perhaps I misunderstood. if you want to reopen, please explain the repro steps, what you expected to happen, and what actually happened
Repro Steps:
Expected behavior:
Claude Code CLI successfully authenticates using these newly created API keys, and I can use the CLI normally.
Actual behavior:
Although new API keys appear in the web console, they are not functional. Claude Code CLI consistently returns:
Additionally, these new API keys in the web UI show no workspace details, and attempting to delete them results in a "Not found" error.
Additional Context:
I strongly suspect archiving the default workspace caused Claude Code CLI to lose reference to its necessary workspace environment, resulting in continuous authentication failures (403 errors).
Could you please reopen and investigate this scenario? Thanks!
same issue here, always get API Error: 403 {"error":{"type":"forbidden","message":"Request not allowed"}}
I create my api-key successfully,but i get the same issue.
!Image
I also check my ip position, it is available.
me 2, did all the api works and returned 403.
I think I find how to handle it. Here is my solution:
!Image
Resolving Claude Code 403 Forbidden Error with a Local Proxy
This guide outlines the steps to resolve the
403 Forbidden: Request not allowederror when using theclaudeCLI tool (or Claude Code integrations like in Cursor) with a local proxy server (e.g., Clash, V2Ray, Surge) on macOS with Zsh.The primary issue seems to be related to how the
claudetool handles theALL_PROXYenvironment variable, especially when set to a SOCKS5 proxy. The solution involves ensuring that onlyHTTP_PROXYandHTTPS_PROXYare set to your local HTTP proxy address and thatALL_PROXYis unset.Prerequisites
http://127.0.0.1:7897).~/.bashrcor~/.bash_profile).Steps to Resolve
1. Modify Your Shell Configuration File (
~/.zshrc)The most reliable way to configure the proxy for your terminal sessions is by setting the environment variables in your shell's startup file.
~/.zshrcfile in a text editor. You can use a terminal editor likenanoorvim, or a graphical editor:``
bash
``nano ~/.zshrc
# Or, for example, with VS Code:
# code ~/.zshrc
http_proxy,https_proxy, orall_proxy(case-insensitive). It's best to remove or comment out old conflicting settings. Add the following lines, preferably towards the end of the file:``
bash
``# Proxy settings for Claude Code and other tools
export HTTP_PROXY="http://127.0.0.1:7897"
export HTTPS_PROXY="http://127.0.0.1:7897"
unset ALL_PROXY # Ensure ALL_PROXY is not set, as it can cause issues with Claude CLI
http://127.0.0.1:7897with the actual HTTP proxy address and port provided by your local proxy client.HTTP_PROXYandHTTPS_PROXYis recommended for broader compatibility.ALL_PROXYhelps prevent conflicts.nano:Ctrl+X, thenY, thenEnter).``
bash
``source ~/.zshrc
2. (Optional but Recommended) Configure
claudeCLI Settings FileThe
claudeCLI tool also has its own settings file at~/.claude/settings.json. While it should respect system environment variables, ensuring its internal configuration is consistent can prevent issues, especially for integrations that might read this file directly.~/.claude/settings.jsonfile:``
bash
``nano ~/.claude/settings.json
``
json
``{
"env": {
"HTTP_PROXY": "http://127.0.0.1:7897",
"HTTPS_PROXY": "http://127.0.0.1:7897"
}
}
http://127.0.0.1:7897with your actual proxy address.ALL_PROXYentry in this JSON file.This can help identify if it's still attempting a direct connection or failing at a specific stage of proxy negotiation.
Perfectly solved!~
People are starting to post strange workarounds here, but I think this misses the root cause:
Currently, we seem to be in the situation where the tokens are created successfully, but then do not work. This is very confusing, and people who archived "Claude Code" cannot even recover from this, since there is no "un-archive" operation.
In our organization, we actually want to have our users in multiple, different workspaces for cost transparency reasons. So ideally, in the login flow, users would be able to choose a workspace from a list of workspaces they have access to. The token would then be created in that workspace. This would be a logical flow and allow us to archive the generic "Claude Code" workspace, which does not make sens for the organization.
So I propose to reopen this to at least fix the confusing situation where API keys get created that don't work. @wolffiex
I found one simple way. when your claude get "OAuth token has expired" just type /login will refresh the token.
@ameame-yzq You the god!! Thank you!!!
@ameame-yzq
Finally resolved! Thank you!!
@ameame-yzq
Thank you!!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.