diff --git a/Keycloak/update-kc.sh b/Keycloak/update-kc.sh index 19b2a8a..a8bddf9 100644 --- a/Keycloak/update-kc.sh +++ b/Keycloak/update-kc.sh @@ -63,12 +63,16 @@ do --data-raw "$line") echo -e " Response : $result\n" default_scopes=$(echo "$line" | jq -r '.defaultClientScopes[]') - clientId=$(echo "$line" | jq -r '.clientId') + CLIENT_UUID=$(curl -sX GET "https://$SOAM_KC/auth/admin/realms/$SOAM_KC_REALM_ID/clients" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $TKN" \ + | jq '.[] | select(.clientId=="'"$CLIENT_ID"'")' | jq -r '.id') + echo "$default_scopes" | while read -r scope; do - echo "$clientId" + echo "$CLIENT_UUID" echo "$scope" #PUT /{realm}/clients/{id}/default-client-scopes/{clientScopeId} - result=$(curl -s -v -w "%{http_code}" -X PUT "$KC_BASE_URL/$KC_REALM_ID/clients/$clientId/default-client-scopes/$scope" \ + result=$(curl -s -v -w "%{http_code}" -X PUT "$KC_BASE_URL/$KC_REALM_ID/clients/$CLIENT_UUID/default-client-scopes/$scope" \ --header "Authorization: Bearer $TKN" \ --header "Content-Type: application/json" \ )