From 5356e0ac64d4bd8bd2d9b3d7b8f5f18ce7e6189f Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Sat, 14 Feb 2026 13:16:32 -0600 Subject: [PATCH] feat: update init-channels to use cookie --- new-api/init-channels.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/new-api/init-channels.sh b/new-api/init-channels.sh index d434b07..8c2197d 100755 --- a/new-api/init-channels.sh +++ b/new-api/init-channels.sh @@ -27,26 +27,26 @@ fi API_BASE="${NEW_API_BASE:-http://localhost:4000}" USERNAME="${NEW_API_USERNAME:-root}" PASSWORD="${NEW_API_PASSWORD:?Set NEW_API_PASSWORD to the admin password}" +COOKIE_JAR=$(mktemp) +trap 'rm -f "$COOKIE_JAR"' EXIT -# ── Login to get session token ────────────────────────── +# ── Login to get session cookie ───────────────────────── login() { echo "Logging in as ${USERNAME}..." local resp - resp=$(curl -s "${API_BASE}/api/user/login" \ + resp=$(curl -s -c "$COOKIE_JAR" "${API_BASE}/api/user/login" \ -H "Content-Type: application/json" \ -d "$(python3 -c " import json, sys print(json.dumps({'username': sys.argv[1], 'password': sys.argv[2]})) " "$USERNAME" "$PASSWORD")") - local success token + local success success=$(echo "$resp" | python3 -c "import sys,json; print(json.load(sys.stdin).get('success', False))") if [[ "$success" != "True" ]]; then echo "ERROR: Login failed: ${resp}" exit 1 fi - - TOKEN=$(echo "$resp" | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['access_token'])") echo " Logged in." } @@ -76,7 +76,7 @@ print(json.dumps({ local resp success resp=$(curl -s "${API_BASE}/api/channel/" \ - -H "Authorization: Bearer ${TOKEN}" \ + -b "$COOKIE_JAR" \ -H "Content-Type: application/json" \ -d "$payload") @@ -150,7 +150,7 @@ create_channel "Cerebras" 1 \ echo "" echo "Creating API token for Open WebUI..." TOKEN_RESP=$(curl -s "${API_BASE}/api/token/" \ - -H "Authorization: Bearer ${TOKEN}" \ + -b "$COOKIE_JAR" \ -H "Content-Type: application/json" \ -d "$(python3 -c " import json