Opencode Oauth Fix banner
fivetaku fivetaku

Opencode Oauth Fix

Development community

Description

OpenCode Anthropic Claude OAuth authentication fix guide and setup script

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

OpenCode OAuth Fix

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_fileReadFile_tool PascalCase + _tool 접미사
Method 2 read_fileread_file_a3f7k2 TTL 기반 접미사 (1시간 캐시)

Method 1이 차단되면 자동으로 Method 2로 전환됩니다.

TTL 캐시 최적화

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 | bash

Step 1: 패치 폴더 생성 및 클론

mkdir -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 install

Step 2: 플러그인 경로 수정

`packages/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  # 사용자 이름 확인

Step 3: OpenCode 빌드

cd ~/Developer/opencode-patch/opencode/packages/opencode
bun run build -- --single

Step 4: PATH 설정

`~/.zshrc` (또는 `~/.bashrc`)에 추가:

export PATH="$HOME/Deve