Created
April 16, 2018 11:52
-
-
Save michaelknurr/7e3d7c4847765e9bbc7f18cc0e67ff78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KC_REALM=<insert realm name here> | |
KC_USERNAME=<username here> | |
KC_PASSWORD=<password here> | |
KC_CLIENT=<client name here> | |
KC_CLIENT_SECRET=<client secret here> | |
KC_SERVER=<server address and port here> | |
KC_CONTEXT=auth | |
# Request Tokens for credentials | |
KC_RESPONSE=$( \ | |
curl -k -v -X POST \ | |
-H "Content-Type: application/x-www-form-urlencoded" \ | |
-d "username=$KC_USERNAME" \ | |
-d "password=$KC_PASSWORD" \ | |
-d 'grant_type=password' \ | |
-d "client_id=$KC_CLIENT" \ | |
-d "client_secret=$KC_CLIENT_SECRET" \ | |
http://$KC_SERVER/$KC_CONTEXT/realms/$KC_REALM/protocol/openid-connect/token \ | |
|jq . | |
) | |
echo Response=$KC_RESPONSE | |
KC_ACCESS_TOKEN=$(echo $KC_RESPONSE| jq -r .access_token) | |
KC_ID_TOKEN=$(echo $KC_RESPONSE| jq -r .id_token) | |
KC_REFRESH_TOKEN=$(echo $KC_RESPONSE| jq -r .refresh_token) | |
# Show all keycloak env variables | |
#set | grep KC_* | |
# Introspect Keycloak Request Token | |
curl -k -v \ | |
-X POST \ | |
-u "$KC_CLIENT:$KC_CLIENT_SECRET" \ | |
-d "token=$KC_ACCESS_TOKEN" \ | |
"http://$KC_SERVER/$KC_CONTEXT/realms/$KC_REALM/protocol/openid-connect/token/introspect" \ | |
| jq . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does introspect work on public clients? Is there any way to verify access token for public clients?