Prefer env vars over secret store for API credentials
All scripts now check GLM_API_KEY / TK_AI_API_TOKEN environment variables first, falling back to Keychain/libsecret only when unset. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -43,17 +43,21 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
# ===== LOAD TOKEN =====
|
||||
case "$OS" in
|
||||
macos)
|
||||
API_TOKEN=$(security find-generic-password -a "$USER" -s "$KEY_NAME" -w 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
arch)
|
||||
API_TOKEN=$(secret-tool lookup service "$KEY_NAME" 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
*)
|
||||
API_TOKEN=$(secret-tool lookup service "$KEY_NAME" 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
esac
|
||||
if [ -n "${!KEY_NAME}" ]; then
|
||||
API_TOKEN="${!KEY_NAME}"
|
||||
else
|
||||
case "$OS" in
|
||||
macos)
|
||||
API_TOKEN=$(security find-generic-password -a "$USER" -s "$KEY_NAME" -w 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
arch)
|
||||
API_TOKEN=$(secret-tool lookup service "$KEY_NAME" 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
*)
|
||||
API_TOKEN=$(secret-tool lookup service "$KEY_NAME" 2>/dev/null | tr -d '\n')
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ -z "$API_TOKEN" ]; then
|
||||
echo -e "${RED}❌ API token not found ($KEY_NAME)${RESET}" >&2
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user