Fixes the WebFetch OAuth 401 error in Claude Code v2.0.22.
Version 2.0.22 removed the anthropic-beta header required for OAuth authentication, causing WebFetch to fail with:
401 API Error: "OAuth authentication is currently not supported."
This script patches your installed Claude Code v2.0.22 to add back the missing header.
# Download the script
curl -O https://gist.githubusercontent.com/[YOUR-USERNAME]/[GIST-ID]/raw/patch-claude-code.sh
chmod +x patch-claude-code.sh
# Apply the patch
./patch-claude-code.sh patch./patch-claude-code.sh status./patch-claude-code.sh unpatchThe script:
- Finds your Claude Code installation automatically
- Creates a backup of the original
cli.js - Adds the missing header:
anthropic-beta: oauth-2025-04-20,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14 - Verifies the patch worked
This is the same header that v2.0.21 includes, which is why v2.0.21 works.
- ✅ Creates automatic backup before modifying anything
- ✅ Can be safely reverted with
unpatchcommand - ✅ Verifies patch applied correctly
- ✅ Minimal change - only adds one header
If you prefer not to patch, downgrade to v2.0.21:
npx @anthropic-ai/claude-code@2.0.21See GitHub Issue #9887 for root cause analysis and HTTP traffic evidence.
- This is a temporary fix until Anthropic releases v2.0.23 with the proper fix
- The script requires write access to your Claude Code installation (may need sudo)
- Tested on macOS with Homebrew installation
- Should work on Linux with npm global installations
"Could not find Claude Code installation"
Specify the location manually:
CLI_JS=/path/to/cli.js ./patch-claude-code.sh patchFind your installation:
# macOS Homebrew
ls /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js
# Linux
ls /usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js
# Find via npm
npm root -g"Permission denied"
Run with sudo:
sudo ./patch-claude-code.sh patch