2
votes

i want to add role to user in specific client keycloak by api in postman but i get "error": "Client not found" this url: POST- http://localhost:8080/auth/admin/realms/{realmName}/users/{userId}/role-mappings/clients/{clientId}

this Body:

  {
   "roles": [
       {
           "id": "0830ff39-43ea-48bb-af8f-696bc420c1ce",
           "name": "confirm-kilid-user",
           "description": "${role_uma_authorization}",
           "composite": false,
           "clientRole": true,
           "containerId": "344e7c81-e7a2-4a43-b013-57d7ed198eee"
       }
   ]
}

1

1 Answers

1
votes

This curl works. We should give clientId ("a48108f0-8465-4f91-8a90-39c72f1a05b8") as containerId and roleId ("36c11a6e-a43a-427c-9c28-90352b369d79") as Id.

curl -X POST \
  http://localhost:7600/auth/admin/realms/adanic/users/4cf43901-663a-4796-bca7-fdfb8642476d/role-mappings/clients/a48108f0-8465-4f91-8a90-39c72f1a05b8 \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJtNnlDZ1ZsbVZRbW5QSmo2UC14Vm1rdG84dnVKNVdhSnlqNTR6d1llSHk0In0.eyJqdGkiOiJjY2U3YTVjNy03YTRmLTQ2ODktYTM2Zi03YjkyOTJhNjlkY2EiLCJleHAiOjE1Nzc1OTg4NDgsIm5iZiI6MCwiaWF0IjoxNTc3NTEyNDQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0Ojc2MDAvYXV0aC9yZWFsbXMvbWFzdGVyIiwic3ViIjoiYzJmOGQwYTctZDYyOC00OWEwLWFhZTUtNzdiMDBkMzRkNjQ4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiYWRtaW4tY2xpIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiN2Q4OThhZjAtN2FkMS00YzVkLTgwNmQtOWQwMTNlNDEwMjY0IiwiYWNyIjoiMSIsInNjb3BlIjoicHJvZmlsZSBlbWFpbCBwaG9uZSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4ifQ.IZ9mx-05mNU2UOvKDXjLbiSbbpoVV7sTKeXAzY7bLbduYApDA9vRsOkUCLB_2Hhdj53Fjp_DxoMKkRsc-D4GIbTTBpKEmB65cH8xsKlt-Ne9vMLW5n_SZRaptTysUHPSfh-NxlUSFwAjXyYp2cH1TQBmUVW3czF1b_8i8b3KAIheq7VLyZcQ8mUTTli1egHlUNLOoqmQO3BEU-fcaI4SPfMHZ4pDWYfFHUJ3B1-be1MTCaVT3LVZKpi7spb-H_o3zmRJnLQdxDqG0-BAIBsytaq6vQ1gf4wzQAzbTvT5VB8FnyRkWID8vum4MW_3XfjABPS2_j1F2cs7Grh7xYd2ew' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 285' \
  -H 'Content-Type: application/json' \
  -H 'Host: localhost:7600' \
  -H 'User-Agent: PostmanRuntime/7.20.1' \
  -H 'cache-control: no-cache' \
  -d ' [
       {
           "id": "36c11a6e-a43a-427c-9c28-90352b369d79",
           "name": "test",
           "description": "${role_create-client}",
           "composite": false,
           "clientRole": true,
           "containerId": "a48108f0-8465-4f91-8a90-39c72f1a05b8"
       }
]