TrueNix/dsh-anthropic-oauth0

dsh-anthropic-oauth

将 Claude Code OAuth (Pro/Max/Team) 桥接至 DSH,复用本地凭证并自动刷新 ANTHROPIC_OAUTH_TOKEN。

AI 分析

核心用途是免去硬编码,将现有的 Claude Code 订阅凭证无缝同步至 DSH。适合拥有 Claude 订阅并希望在 DSH 中直接使用该通道的用户。

包名
dsh-anthropic-oauth
版本
0.1.0
许可证
NOASSERTION
最近更新
2026年8月18日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:TrueNix/dsh-anthropic-oauth

dsh-anthropic-oauth

Bridge your existing Claude Code OAuth session (Pro / Max / Team) into DeepSeek Harness (DSH) — with zero hardcoding.

  • Reads ~/.claude/.credentials.json claudeAiOauth live (same file Claude Code writes)
  • Auto-refreshes accessToken via https://platform.claude.com/v1/oauth/token when dsh-anthropic-oauth Host plugin claudeAiOauth {accessToken, refreshToken, expiresAt} │ refreshIfNeeded() if expiry <5m POST https://platform.claude.com/v1/oauth/token {grant_type: refresh_token, client_id: 9d1c25…f5e} │ ├─► ~/.claude/.credentials.json (updated expiry) └─► ~/.dsh/.credentials.yaml ANTHROPIC_OAUTH_TOKEN: sk-ant-oat01-… CLAUDE_CODE_OAUTH_TOKEN: sk-ant-oat01-…

~/.dsh/settings.yaml llm-pi-ai.providers.anthropic {apiKeyEnv: ANTHROPIC_OAUTH_TOKEN} │ └─► pi-ai anthropicMessagesApi — Authorization: Bearer sk-ant-oat01-… anthropic-beta: claude-code-20250219,oauth-2025-04-20


Verified live: `haiku-4.5` streaming returns `dsh-pi-ai ok` over the same `Bearer` path.

## Set as default model

```yaml
# ~/.dsh/settings.yaml
agent-default-model:
  provider: anthropic
  model: claude-sonnet-4-5

Or pick per-session in Settings → Models after a reload.

Logs & manual sync

journalctl --user -u dsh-anthropic-oauth-bridge -f  # legacy external bridge (pre-plugin)
# plugin logs:
# DSH console: [anthropic-oauth] ...
node ~/Workspace/sync-claude-oauth.mjs   # manual one-shot (legacy)

Troubleshooting

  • MISSING_CREDENTIAL llm-pi-ai: no credential for provider route "anthropic" — bridge hasn't synced yet; run node ~/Workspace/sync-claude-oauth.mjs or re-login with claude.
  • state mismatch during manual paste — you pasted a code from a different PKCE verifier.
  • 401 from Anthropic — token expired and refresh failed; claude login again.

Security

  • Never commits tokens — .gitignore excludes *.oat*, *.credentials.*.
  • Tokens live only in 0600 files owned by you: ~/.claude/.credentials.json and ~/.dsh/.credentials.yaml.
  • A Feb-2026 Anthropic docs note declares Pro/Max OAuth for official clients only — personal use at your own risk; use a console ANTHROPIC_API_KEY for production.

License

MIT