From 2f377b2cdfe91c8e1f2fbffac6bf8313a7d2168e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 21 Oct 2025 21:21:49 +0800 Subject: [PATCH] Fix read credentials for ccm service --- docs/configuration/service/ccm.md | 4 +++- docs/configuration/service/ccm.zh.md | 4 +++- service/ccm/credential.go | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/configuration/service/ccm.md b/docs/configuration/service/ccm.md index e0ccfa1f8..28b82710c 100644 --- a/docs/configuration/service/ccm.md +++ b/docs/configuration/service/ccm.md @@ -37,7 +37,9 @@ See [Listen Fields](/configuration/shared/listen/) for details. Path to the Claude Code OAuth credentials file. -Defaults to `~/.claude/.credentials.json` if not specified. +If not specified, defaults to: +- `$CLAUDE_CONFIG_DIR/.credentials.json` if `CLAUDE_CONFIG_DIR` environment variable is set +- `~/.claude/.credentials.json` otherwise On macOS, credentials are read from the system keychain first, then fall back to the file if unavailable. diff --git a/docs/configuration/service/ccm.zh.md b/docs/configuration/service/ccm.zh.md index fa5e5d512..cd5d34715 100644 --- a/docs/configuration/service/ccm.zh.md +++ b/docs/configuration/service/ccm.zh.md @@ -37,7 +37,9 @@ CCM(Claude Code 多路复用器)服务是一个多路复用服务,允许 Claude Code OAuth 凭据文件的路径。 -如果未指定,默认使用 `~/.claude/.credentials.json`。 +如果未指定,默认值为: +- 如果设置了 `CLAUDE_CONFIG_DIR` 环境变量,则使用 `$CLAUDE_CONFIG_DIR/.credentials.json` +- 否则使用 `~/.claude/.credentials.json` 在 macOS 上,首先从系统钥匙串读取凭据,如果不可用则回退到文件。 diff --git a/service/ccm/credential.go b/service/ccm/credential.go index 5fd797215..695efc7ae 100644 --- a/service/ccm/credential.go +++ b/service/ccm/credential.go @@ -32,6 +32,9 @@ func getRealUser() (*user.User, error) { } func getDefaultCredentialsPath() (string, error) { + if configDir := os.Getenv("CLAUDE_CONFIG_DIR"); configDir != "" { + return filepath.Join(configDir, ".credentials.json"), nil + } userInfo, err := getRealUser() if err != nil { return "", err