fix: use CLAUDE_CODE_OAUTH_TOKEN for OAuth authentication
This commit is contained in:
@@ -261,9 +261,19 @@ impl ClaudeCodeClient {
|
|||||||
.arg("--include-partial-messages")
|
.arg("--include-partial-messages")
|
||||||
.arg("--dangerously-skip-permissions");
|
.arg("--dangerously-skip-permissions");
|
||||||
|
|
||||||
// Set API key if configured
|
// Set API key or OAuth token if configured
|
||||||
if let Some(ref api_key) = self.config.api_key {
|
// OAuth tokens start with "sk-ant-oat" and must use CLAUDE_CODE_OAUTH_TOKEN
|
||||||
cmd.env("ANTHROPIC_API_KEY", api_key);
|
// API keys start with "sk-ant-api" and use ANTHROPIC_API_KEY
|
||||||
|
if let Some(ref key) = self.config.api_key {
|
||||||
|
if key.starts_with("sk-ant-oat") {
|
||||||
|
// OAuth access token
|
||||||
|
cmd.env("CLAUDE_CODE_OAUTH_TOKEN", key);
|
||||||
|
debug!("Using OAuth token for Claude CLI authentication");
|
||||||
|
} else {
|
||||||
|
// Regular API key
|
||||||
|
cmd.env("ANTHROPIC_API_KEY", key);
|
||||||
|
debug!("Using API key for Claude CLI authentication");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model selection
|
// Model selection
|
||||||
|
|||||||
Reference in New Issue
Block a user