Created
October 6, 2022 15:26
-
-
Save xgp/f58cf86eff6e1e131427670b2d281191 to your computer and use it in GitHub Desktop.
Example to create org
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 | |
read -p 'Host (format https://euc1.auth.ac ): ' host | |
read -p 'Realm: ' realm | |
printf "\nThis user must have create-organization, manage-organizations, and view-organizations realm-management roles in order to create and manage new Organizations.\n"read -p 'Username: ' user | |
read -p 'Username: ' user | |
read -sp 'Password: ' pass | |
DIRECT_GRANT_RESPONSE=$(curl -i --request POST $host/auth/realms/$realm/protocol/openid-connect/token --header "Accept: application/json" --header "Content-Type: application/x-www-form-urlencoded" --data "grant_type=password&username=$user&password=$pass&client_id=admin-cli") | |
ACCESS_TOKEN=$(echo $DIRECT_GRANT_RESPONSE | grep "access_token" | sed 's/.*\"access_token\":\"\([^\"]*\)\".*/\1/g'); | |
# get orgs | |
curl $host/auth/realms/$realm/orgs --header "Accept: application/json" --header "Authorization: Bearer $ACCESS_TOKEN" | |
# create an org | |
curl --request POST $host/auth/realms/$realm/orgs --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer $ACCESS_TOKEN" -d '{"name":"fubar","displayName":"Foo Bar","url":"https://fubar.com"}' | |
# get orgs, again | |
curl $host/auth/realms/$realm/orgs --header "Accept: application/json" --header "Authorization: Bearer $ACCESS_TOKEN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Required user roles:
