Skip to content

Instantly share code, notes, and snippets.

@vodolaz095
Last active February 5, 2025 08:44
Show Gist options
  • Save vodolaz095/d93839528ee95d098af95b5fa091d814 to your computer and use it in GitHub Desktop.
Save vodolaz095/d93839528ee95d098af95b5fa091d814 to your computer and use it in GitHub Desktop.
Makefile: obtain jwt token from keycloack and make requests via curl using this token
# obtain keycloack jwt token and store in in variable
export token=$(shell curl -s -k -X POST \
-d 'grant_type=password' \
-d 'username=somebody' \
-d 'password=longPasswordToMakeHackersSad333222111' \
-d 'scope=email%20profile%20openid' \
-d 'client_id=somebody' \
-d 'client_secret=""' \
--connect-timeout 5 \
https://keycloack.local/oidc/realms/something/protocol/openid-connect/token | jq '.["access_token"]')
export bearer="Authorization: Bearer $(token)"
export api_server="http://localhost:3000/"
# send request to backend, performing Bearer authorization with keycloack token obtained
integration/get_something:
curl -s -H $(bearer) $(api_server)api/v1/get_something/ | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment