Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created June 16, 2017 12:52
Show Gist options
  • Save chmouel/c9039cd37757f0a23244361ff1cc46a9 to your computer and use it in GitHub Desktop.
Save chmouel/c9039cd37757f0a23244361ff1cc46a9 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -ef
# dont put slash at the end or that would fail
URL=""
TOKEN=$(curl -f -k -s -k "${URL}/auth/realms/master/protocol/openid-connect/token" -H "Content-Type: application/x-www-form-urlencoded" -d "username=admin" -d 'password=admin' -d 'grant_type=password' -d 'client_id=admin-cli'|python -c 'import sys, json; print json.load(sys.stdin)["access_token"]')
curl -f -s -k "${URL}/auth/admin/realms" -H "Accept: application/json" -H "Authorization: Bearer $TOKEN" | python -mjson.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment