Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Keycloak Admin API Rest Example
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/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' | jq -r '.access_token')
curl -X GET 'http://localhost:8080/auth/admin/realms' \
-H "Accept: application/json" \
-H "Authorization: Bearer $TKN" | jq .
@phuongtailtranminh

This comment has been minimized.

Copy link

commented Apr 21, 2017

OSX - Use Homebrew to install jq 1.5 with brew install jq.

@johnreytanquinco

This comment has been minimized.

Copy link

commented Feb 20, 2018

Hi, I am trying to run this script but getting the response below.

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   156  100    80  100    76     57     54  0:00:01  0:00:01 --:--:--    57
parse error: Invalid numeric literal at line 1, column 54
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     6  100     6    0     0      5      0  0:00:01  0:00:01 --:--:--     5
parse error: Invalid numeric literal at EOF at line 1, column 6

I assume this has to do with the proper use of quotes?

@avoidik

This comment has been minimized.

Copy link

commented Feb 28, 2018

@johnreytanquinco I guess you have to check encoding of the script-file, it should be LF, not CRLF

@Allan-Nava

This comment has been minimized.

Copy link

commented Mar 22, 2018

Login with python - request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.