From 8908008391ccf04f1c302173f56d0ef2d6e4cc82 Mon Sep 17 00:00:00 2001 From: Marc M <8666222+marcmantei@users.noreply.github.com> Date: Thu, 7 May 2026 21:12:35 +0200 Subject: [PATCH 1/2] fix(providers): detect Anthropic OAuth credentials in provider status The get_providers() endpoint only checks for ANTHROPIC_API_KEY env var or config file key to determine if Anthropic is available. It does not check for anthropic_oauth.json, causing the dashboard to report Anthropic as "not configured" for users authenticating via OAuth (Claude Pro/Max subscription). This mirrors the existing pattern already used for OpenAI OAuth detection via openai_oauth_configured. Minimal alternative to #430. Co-Authored-By: Claude Co-Authored-By: Happy --- src/api/providers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/providers.rs b/src/api/providers.rs index ec8f67de0..52f6af4e5 100644 --- a/src/api/providers.rs +++ b/src/api/providers.rs @@ -374,6 +374,7 @@ pub(super) async fn get_providers( let instance_dir = (**state.instance_dir.load()).clone(); let secrets_store = state.secrets_store.load(); let openai_oauth_configured = crate::openai_auth::credentials_path(&instance_dir).exists(); + let anthropic_oauth_configured = crate::auth::credentials_path(&instance_dir).exists(); let env_set = |name: &str| { std::env::var(name) .ok() @@ -450,7 +451,7 @@ pub(super) async fn get_providers( }; ( - has_value("anthropic_key", "ANTHROPIC_API_KEY"), + has_value("anthropic_key", "ANTHROPIC_API_KEY") || anthropic_oauth_configured, has_value("openai_key", "OPENAI_API_KEY"), openai_oauth_configured, has_value("openrouter_key", "OPENROUTER_API_KEY"), @@ -482,7 +483,7 @@ pub(super) async fn get_providers( ) } else { ( - env_set("ANTHROPIC_API_KEY"), + env_set("ANTHROPIC_API_KEY") || anthropic_oauth_configured, env_set("OPENAI_API_KEY"), openai_oauth_configured, env_set("OPENROUTER_API_KEY"), From 499d1e8a447f7f7721809448286bc010b1a73971 Mon Sep 17 00:00:00 2001 From: Marc M <8666222+marcmantei@users.noreply.github.com> Date: Sat, 16 May 2026 13:56:47 +0200 Subject: [PATCH 2/2] fix(providers): remove OAuth credentials file on provider deletion When delete_provider("anthropic") is called, also remove the anthropic_oauth.json file from disk. Without this, the provider detection added in the previous commit would still report Anthropic as configured after deletion. Mirrors the existing "openai-chatgpt" deletion handling pattern. Co-Authored-By: Claude Co-Authored-By: Happy --- src/api/providers.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/providers.rs b/src/api/providers.rs index 52f6af4e5..0d48f52c4 100644 --- a/src/api/providers.rs +++ b/src/api/providers.rs @@ -1513,6 +1513,20 @@ pub(super) async fn delete_provider( })); } + // Anthropic OAuth credentials are stored as a separate JSON file. + // Remove it so that get_providers no longer reports Anthropic as configured. + if provider == "anthropic" { + let instance_dir = (**state.instance_dir.load()).clone(); + let cred_path = crate::auth::credentials_path(&instance_dir); + if cred_path.exists() { + tokio::fs::remove_file(&cred_path).await.map_err(|error| { + tracing::error!(%error, path = %cred_path.display(), "failed to remove Anthropic OAuth credentials"); + StatusCode::INTERNAL_SERVER_ERROR + })?; + } + // Fall through to also remove the TOML key if present. + } + // GitHub Copilot has a cached token file alongside the TOML key. // Remove both the TOML key and the cached token. if provider == "github-copilot" {