I already have a running Keycloak instance with a lot of registered users. How can I add a new custom attribute (with an empty value) to all users without doing it manually?
How can I add a new custom attribute (with an empty value) to all users without doing it manually?
You can use Keycloak Rest Admin API:
First you use endpoint
GET /{realm}/users
to get all the users. Then for each user you extract its ID an call the endpoint :
PUT /{realm}/users/{id}
with the payload {"attributes": <old Attributes> + < new Attributes>}
I have create a bash script for this in my repo. Running example:
sh addAttributeToAllUsers.sh localhost:8080 admin admin test '{"c":["c"]}'