Skip to content

Commit b035d75

Browse files
committed
Fix manual anthropic login to save credentials in global config instead of cache.
1 parent 977b6dc commit b035d75

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix manual anthropic login to save credentials in global config instead of cache.
6+
57
## 0.51.2
68

79
- Minor log improvement of failed to start MCPs.

src/eca/llm_providers/anthropic.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[cheshire.core :as json]
44
[clojure.java.io :as io]
55
[clojure.string :as string]
6+
[eca.config :as config]
67
[eca.features.login :as f.login]
78
[eca.llm-util :as llm-util]
89
[eca.logger :as logger]
@@ -328,11 +329,11 @@
328329

329330
(defmethod f.login/login-step ["anthropic" :login/waiting-api-key] [{:keys [db* input provider send-msg!] :as ctx}]
330331
(if (string/starts-with? input "sk-")
331-
(do (swap! db* assoc-in [:auth provider] {:step :login/done
332-
:type :auth/token
333-
:mode :manual
334-
:api-key input})
335-
(f.login/login-done! ctx))
332+
(do
333+
(config/update-global-config! {:providers {"anthropic" {:key input}}})
334+
(swap! db* dissoc :auth provider)
335+
(send-msg! (format "API key and models saved to %s" (.getCanonicalPath (config/global-config-file))))
336+
(f.login/login-done! ctx))
336337
(send-msg! (format "Invalid API key '%s'" input))))
337338

338339
(defmethod f.login/login-step ["anthropic" :login/renew-token] [{:keys [db* provider] :as ctx}]

src/eca/llm_providers/azure.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
{}
3131
(string/split input #","))
3232
:key api-key}}}))
33-
(swap! db* assoc-in [:auth provider] nil)
33+
(swap! db* dissoc :auth provider)
3434
(send-msg! (format "API key, url and models saved to %s" (.getCanonicalPath (config/global-config-file))))
3535
(f.login/login-done! ctx))

src/eca/llm_providers/deepseek.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
{}
2525
(string/split input #","))
2626
:key api-key}}}))
27-
(swap! db* assoc-in [:auth provider] nil)
27+
(swap! db* dissoc :auth provider)
2828
(send-msg! (format "API key and models saved to %s" (.getCanonicalPath (config/global-config-file))))
2929
(f.login/login-done! ctx))

src/eca/llm_providers/openai.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
(defmethod f.login/login-step ["openai" :login/waiting-api-key] [{:keys [input db* provider send-msg!] :as ctx}]
206206
(if (string/starts-with? input "sk-")
207207
(do (config/update-global-config! {:providers {"openai" {:key input}}})
208-
(swap! db* assoc-in [:auth provider] nil)
208+
(swap! db* dissoc :auth provider)
209209
(send-msg! (str "API key saved in " (.getCanonicalPath (config/global-config-file))))
210210

211211
(f.login/login-done! ctx :update-cache? false))

src/eca/llm_providers/openrouter.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
{}
2525
(string/split input #","))
2626
:key api-key}}}))
27-
(swap! db* assoc-in [:auth provider] nil)
27+
(swap! db* dissoc :auth provider)
2828
(send-msg! (format "API key and models saved to %s" (.getCanonicalPath (config/global-config-file))))
2929
(f.login/login-done! ctx))

src/eca/llm_providers/z_ai.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
{}
2525
(string/split input #","))
2626
:key api-key}}}))
27-
(swap! db* assoc-in [:auth provider] nil)
27+
(swap! db* dissoc :auth provider)
2828
(send-msg! (format "API key and models saved to %s" (.getCanonicalPath (config/global-config-file))))
2929
(f.login/login-done! ctx))

0 commit comments

Comments
 (0)