Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak Admin REST API: query more than 100 resource objects

I have a client in Keycloak with more than 100 resources. And I am trying to query the id of a resource with the Keycloak Admin REST API the following way:

RESOURCE_ID=$(curl -k -s -H "Authorization: bearer $ACCESS_TOKEN" "$KEYCLOAK_URL/auth/admin/realms/$REALM/clients/$CLIENT_ID/authz/resource-server/resource" | jq -r '.[] | select(.name=="xy resource")._id')

Unfortunatelly "xy resource" is at the end of the alphabetically ordered list and the curl gives back only th first 100 resource objects.

Is there a way to query more than 100 records with the Keycloak Admin REST API or query directly the one with the given name?

I use Keycloak 12.0.4.

like image 387
Donato Szilagyi Avatar asked Feb 01 '26 03:02

Donato Szilagyi


2 Answers

I have a client in Keycloak with more than 100 resources. And I am trying to query the id of a resource with the Keycloak Admin REST API

Go get more than 100 resources, you just need to set the max parameter to -1 for example:

https://{KEYCLOACK_URL}/admin/realms/{MY_REALM}/users?max=-1
like image 74
dreamcrash Avatar answered Feb 03 '26 23:02

dreamcrash


Please check REST API documentation, there are a lot of Query optional parameter 'max'

Maximum results size (defaults to 100) integer(int32)

https://www.keycloak.org/docs-api/7.0/rest-api/

like image 28
Gulyás István Avatar answered Feb 03 '26 23:02

Gulyás István