Skip to content

Commit a9dd24f

Browse files
lidge-junclaude
andcommitted
feat(70): Windows/Linux use own OAuth storage, drop secret-tool detection
Make Claude Code auto-import macOS-only (Keychain). On Windows/Linux, opencodex relies on its own OAuth flow (ocx login → ~/.opencodex/auth.json) instead of platform credential managers. Platform-aware error messages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be4397b commit a9dd24f

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/oauth/anthropic.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ export async function loginAnthropic(
135135
}
136136
}
137137
} else if (importLocal === "only") {
138-
throw new Error("No Claude Code token found in the keychain. Run 'ocx login anthropic' for browser OAuth.");
138+
throw new Error(
139+
process.platform === "darwin"
140+
? "No Claude Code token found in the keychain. Run 'ocx login anthropic' for browser OAuth."
141+
: "Claude Code auto-import is macOS-only. Run 'ocx login anthropic' for browser OAuth.",
142+
);
139143
}
140144
}
141145
return new AnthropicOAuthFlow(ctrl).login();

src/oauth/local-token-detect.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,13 @@ export function detectGrokCliToken(): OAuthCredentials | null {
3838
}
3939
}
4040

41-
/** Read the Claude Code OAuth credential from the OS secure store (macOS keychain / linux secret-tool). */
41+
/** Read the Claude Code OAuth credential from macOS Keychain. Windows/Linux: use `ocx login`. */
4242
function readClaudeSecureStorage(): string | null {
43+
if (process.platform !== "darwin") return null;
4344
try {
44-
if (process.platform === "darwin") {
45-
return execSync(`security find-generic-password -s "${CLAUDE_KEYCHAIN_SERVICE}" -w`, {
46-
encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"],
47-
}).trim();
48-
}
49-
if (process.platform === "linux") {
50-
return execSync(`secret-tool lookup service "${CLAUDE_KEYCHAIN_SERVICE}"`, {
51-
encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"],
52-
}).trim();
53-
}
54-
return null;
45+
return execSync(`security find-generic-password -s "${CLAUDE_KEYCHAIN_SERVICE}" -w`, {
46+
encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"],
47+
}).trim();
5548
} catch {
5649
return null;
5750
}

0 commit comments

Comments
 (0)