79630853

Date: 2025-05-20 16:56:20
Score: 1
Natty:
Report link

It's easy to set this setting in the GUI but I need to set it automatically.

You can do all the things using REST which are possible though GUI. Keycloak documentation does not provide all the endpoints. You can refer to the REST calls made by GUI by analyzing network calls from debugger.

How to use REST APIs?
Use temporary Keycloak admin credentials (which you must have created while installing keycloak) to generate access token.

MASTER_TOKEN=$(curl --silent --location --request POST "http://localhost:8080/realms/master/protocol/openid-connect/token" \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=admin-cli' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin' | jq -r '.access_token')

Using this token, you can perform all the operations that you are performing from GUI.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Jay Dudhatra