OpenCode에서 Anthropic Claude OAuth 인증 오류를 해결하는 가이드입니다.
English version below
OpenCode에서 Claude Pro/Max OAuth 인증 시 다음 오류 발생:
This credential is only authorized for use with Claude Code and cannot be used for other API requests.
다층 우회 방식 + TTL 기반 캐시 최적화가 적용된 패치를 사용합니다.
| 방법 | 변환 예시 | 설명 |
|---|---|---|
| Method 1 | read_file → ReadFile_tool |
PascalCase + _tool 접미사 |
| Method 2 | read_file → read_file_a3f7k2 |
TTL 기반 접미사 (1시간 캐시) |
Method 1이 차단되면 자동으로 Method 2로 전환됩니다.
Method 2는 매 요청마다 랜덤 접미사를 생성하는 대신, 1시간 동안 동일한 접미사를 재사용합니다:
- Anthropic API 캐시 히트율 향상
- 1시간마다 접미사 로테이션으로 탐지 회피
curl -fsSL https://raw.githubusercontent.com/fivetaku/opencode-oauth-fix/main/scripts/setup.sh | bash또는 스크립트를 다운로드 후 실행:
git clone https://github.com/fivetaku/opencode-oauth-fix.git
cd opencode-oauth-fix
chmod +x scripts/setup.sh
./scripts/setup.sh- Bun v1.3.5 이상
- Git
# Bun 설치 (없는 경우)
curl -fsSL https://bun.sh/install | bashmkdir -p ~/Developer/opencode-patch
cd ~/Developer/opencode-patch
# 플러그인 클론 (TTL 최적화 버전)
git clone -b pr-13 https://github.com/fivetaku/opencode-anthropic-auth.git
cd opencode-anthropic-auth
bun install
cd ..
# OpenCode 클론
git clone https://github.com/anomalyco/opencode.git
cd opencode
bun installpackages/opencode/src/plugin/index.ts 파일에서 플러그인 경로를 수정합니다:
const BUILTIN = [
"opencode-copilot-auth@0.0.9",
"file:///Users/YOUR_USERNAME/Developer/opencode-patch/opencode-anthropic-auth/index.mjs"
]YOUR_USERNAME을 본인의 macOS 사용자 이름으로 변경하세요:
whoami # 사용자 이름 확인cd ~/Developer/opencode-patch/opencode/packages/opencode
bun run build -- --single~/.zshrc (또는 ~/.bashrc)에 추가:
export PATH="$HOME/Developer/opencode-patch/opencode/packages/opencode/dist/opencode-darwin-arm64/bin:$PATH"적용:
source ~/.zshrcwhich opencode
# /Users/YOUR_USERNAME/Developer/opencode-patch/opencode/.../bin/opencode
opencode --version
# 0.0.0-dev-YYYYMMDDHHMMopencodeMethod 1이 막힌 경우 환경변수로 강제 전환:
export OPENCODE_USE_RANDOMIZED_TOOLS=true
opencode패치를 제거하고 원래 버전으로 돌아가려면:
~/.zshrc에서 PATH 라인 삭제source ~/.zshrc실행- (옵션) 패치 폴더 삭제:
rm -rf ~/Developer/opencode-patch
문제가 있거나 개선 사항이 있으면 Issue를 열어주세요!
When using Claude Pro/Max OAuth authentication in OpenCode:
This credential is only authorized for use with Claude Code and cannot be used for other API requests.
Apply the multi-layered bypass with TTL-based cache optimization.
| Method | Example | Description |
|---|---|---|
| Method 1 | read_file → ReadFile_tool |
PascalCase + _tool suffix |
| Method 2 | read_file → read_file_a3f7k2 |
TTL-based suffix (1hr cache) |
Method 2 reuses the same suffix for 1 hour instead of generating a new one per request:
- Improves Anthropic API cache hit rate
- Rotates suffix hourly for detection avoidance
curl -fsSL https://raw.githubusercontent.com/fivetaku/opencode-oauth-fix/main/scripts/setup.sh | bash- Bun v1.3.5+
- Git
# 1. Create patch directory
mkdir -p ~/Developer/opencode-patch
cd ~/Developer/opencode-patch
# 2. Clone plugin with TTL optimization
git clone -b pr-13 https://github.com/fivetaku/opencode-anthropic-auth.git
cd opencode-anthropic-auth
bun install
cd ..
# 3. Clone and setup OpenCode
git clone https://github.com/anomalyco/opencode.git
cd opencode
bun install
# 4. Update plugin path in packages/opencode/src/plugin/index.ts
# Change YOUR_USERNAME to your macOS username (run: whoami)
# 5. Build
cd packages/opencode
bun run build -- --single
# 6. Add to PATH (~/.zshrc or ~/.bashrc)
export PATH="$HOME/Developer/opencode-patch/opencode/packages/opencode/dist/opencode-darwin-arm64/bin:$PATH"
# 7. Apply
source ~/.zshrcMIT
Last Updated: 2026-01-09