25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

22 satır
915 B

  1. #!/bin/bash
  2. # Get OAuth token from auth server. Set AUTH_URL and form data for your environment.
  3. # Usage: ./auth/token.sh (prints token to stdout)
  4. # Example with token: TOKEN=$(./scripts/auth/token.sh) && curl -H "Authorization: Bearer $TOKEN" "$BASE_URL/reslevis/getTrackers"
  5. AUTH_URL="${AUTH_URL:-https://10.251.0.30:10002/realms/API.Server.local/protocol/openid-connect/token}"
  6. TOKEN=$(curl -k -s -X POST "$AUTH_URL" \
  7. -H "Content-Type: application/x-www-form-urlencoded" \
  8. -d "grant_type=password" \
  9. -d "client_id=${CLIENT_ID:-Fastapi}" \
  10. -d "client_secret=${CLIENT_SECRET}" \
  11. -d "username=${USERNAME}" \
  12. -d "password=${PASSWORD}" \
  13. -d "audience=${AUDIENCE:-Fastapi}" \
  14. | jq -r '.access_token')
  15. if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
  16. echo "Failed to get token. Set CLIENT_SECRET, USERNAME, PASSWORD (and optionally AUTH_URL, CLIENT_ID, AUDIENCE)." >&2
  17. exit 1
  18. fi
  19. echo "$TOKEN"