Is it possible to update the value of custom attribute via Keycloak REST API? For example, which endpoint to use and how to construct a request body for the attribute that was created here.
Thanks!
Add custom attribute Before we start, you must be logged in as an admin in keycloak. In the left menu bar click on Users , choose a user, in our case (johndoe) and the click Attributes tab. Enter a key and value and click the Add button on the right side. Now click the Save button.
Adding Custom attributes to our Realm We will add a Custom Attribute from Keycloak Admin application. Select the Users Panel and check the Attributes Tab. There Click to Add an Attribute and Save it. We have now added the customer.id Custom Attribute.
Keycloak is a third-party authorization server that manages users of our web or mobile applications. It offers some default attributes, such as first name, last name, and email to be stored for any given user.
You have to use Keycloak Admin REST API :
PUT {host}/{basepath}/admin/realms/{realm}/users/{id}
e.g.
http://localhost:8080/auth/admin/realms/alumni-realm/users/cd57cfd8-cb1c-4025-abfd-67fe6b784d22
Request Body (JSON) :
{
"attributes": {
"DOB": "1984-07-01"
}
}
Authorization (Bearer Token) :
Use Admin user
access_token for authorization.
If you want to allow User
to update their own profile then you have to grant manage-users
role in Keycloak. (That user will be able to update other users info hence it is not recommended)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With