Reputation: 31
I want to retrieve some of the parameter/values from keycloak (Maria db) data through REST API.
These are the parameters which i am looking to retrieve from Keycloak through REST API:
Realm Name
Realm ID
Keycloak Admin-Users
Username
First Name
Last Name
Realm ID
User Enabled
Is there anyone using REST APIs to fetch these details from keycloak, Could you please share the REST API URL details for the same.
Upvotes: 2
Views: 7451
Reputation: 3456
Create service user, make sure user has role "realm-management"->"view-users" (might be query-users as well)
Process is simple: do login to keycloak with service user (keep password and/or user name encoded in the properties file), make request to keycloak with accessToken in authorisation header to
GET http://{yourdomainadress}/auth/admin/realms/{yourrealmname}/users
A way to login to keycloak using REST API:
POST http://{yourdomainadress}/auth/realms/{yourrealmname}/protocol/openid-connect/token
Headers:
Content-Type: application/x-www-form-urlencoded
Body x-www-form-urlencoded:
client_id: your-client
username: user-you-are-using
password: password-for-user
grant_type: password
client_secret: 11112222-3333-4444-5555-666666666666 (client secret is required if client "Access Type"="confidential")
Upvotes: 2
Reputation: 707
You should edit this api url with the information of your keycloak instance.
http://{yourdomainadress}/auth/admin/realms/{yourrealmname}/users
You can not get Realm ID with api.
Check the documentation for the users api parameters
Upvotes: 0