Last active
June 18, 2024 15:32
-
-
Save lukaszbudnik/05425886bfb2fcca99f42da5c2b3ae54 to your computer and use it in GitHub Desktop.
youtube.com - Keycloak Multi-Tenant JavaScript Clients
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
# don't forget to update below variables to point to your Keycloak instance, main realm, and admin user | |
export KEYCLOAK_URL="http://localhost:8080" | |
export KEYCLOAK_MAIN_REALM=master | |
export KEYCLOAK_USER=lb | |
export KEYCLOAK_PASSWORD=*** | |
# get the access token | |
access_token=$(curl --silent \ | |
-d "client_id=admin-cli" \ | |
-d "username=$KEYCLOAK_USER" \ | |
-d "password=$KEYCLOAK_PASSWORD" \ | |
-d "grant_type=password" \ | |
"$KEYCLOAK_URL/auth/realms/$KEYCLOAK_MAIN_REALM/protocol/openid-connect/token" | jq -r '.access_token') | |
# create customer100 realm | |
curl -v -X POST -H "Authorization: bearer $access_token" -H "Content-Type: application/json" --data-binary @new_realm.json $KEYCLOAK_URL/auth/admin/realms | |
# check if realm created successfully | |
curl -H "Authorization: bearer $access_token" $KEYCLOAK_URL/auth/admin/realms/customer100 | jq | |
# create react client | |
curl -v -X POST -H "Authorization: bearer $access_token" -H "Content-Type: application/json" --data-binary @new_client.json $KEYCLOAK_URL/auth/admin/realms/customer100/clients | |
# check if client created successfully | |
curl -H "Authorization: bearer $access_token" $KEYCLOAK_URL/auth/admin/realms/customer100/clients?clientId=react | jq |
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
{ | |
"clientId": "react", | |
"rootUrl": "http://customer100.localtest.me:3000", | |
"enabled": true, | |
"redirectUris": [ | |
"http://customer100.localtest.me:3000/*" | |
], | |
"webOrigins": [ | |
"http://customer100.localtest.me:3000" | |
], | |
"publicClient": true, | |
"protocol": "openid-connect" | |
} |
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
{ | |
"id": "customer100", | |
"realm": "customer100", | |
"enabled": true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment