0

Is there any possible solutions to update a client authz settings with a registrationAccessToken (without passing by admin credentials) ?

Suppose my keycloak server (v15.0.2) is at https://keycloak.local

What I am to try is this:

I create a client with client default registration on the URI https://keycloak.local/auth/realms/myrealm/clients-registrations/default passing clientId in the POST body.

I retrieve the registrationAccessToken in the response.

According to doc (https://github.com/keycloak/keycloak-documentation/blob/main/securing_apps/topics/client-registration.adoc) We may update the client by passing a ClientRepresentation and using registrationAccessToken But when I pass in this json, authorizationSettings, there a not change on the client in the UI...


import requests

# Initial token created in the UI
initial_token = "xxxxx"

client_id = "new_client"

data = {"clientId": client_id}

# The first time we use intial token.
headers = {
    "Content-Type": "application/json",
    "Authorization": "bearer {}".format(initial_token)
}

# Creating the client
resp = requests.post(https://keycloak.local/auth/realms/myrealm/clients-registrations/default, headers=headers, data=data)

# New Bearer  with registration access token coming from response
headers["Authorization"] = "bearer {}" .format(resp.json()["registrationAccessToken"])

# We want to turn off allowRemoteResourceManagement (default to true)
data = json.dumps({
"authorizationSettings": {"allowRemoteResourceManagement": False}
})

resp = requests.put(https://keycloak.local/auth/realms/myrealm/clients-registrations/default, headers=headers, verify=False,data)

No change in the keycloak authorization settings in the UI....

Why ?

Achraf Bentabib
  • 72
  • 1
  • 13

0 Answers0