[SOLVED]: Unable to login in using Admin REST API for simple setup

Hello,

  • I am running a standard installation of Keycloak 26.1.0.
  • I have a single realm, R, configured; the realm has the standard set of clients and one additional client, C, for my application.
  • I would like to use the Admin REST API to administer users for this realm.
  • The server developer guide states the following to login:
curl \
  -d "client_id=admin-cli" \
  -d "username=admin" \
  -d "password=password" \
  -d "grant_type=password" \
  "http://localhost:8080/realms/master/protocol/openid-connect/token"
  • I changed the hostname and realm; I supplied the credentials of an admin user for the target realm. The target client is the ‘admin-cli’.
  • I verified that I can log into the web interface to administer the realm with the admin user’s credentials. In fact, I do that all the time.

However I get the following error message when I invoke the API:
{"error":"invalid_grant","error_description":"Invalid user credentials"}

I am unable to discover any material information on how to solve this issue and would appreciate any guidance.

[ What I have seen on the internet but that I am skeptical of is: due the the OTP (optional) in the direct grant Flow ]

Lastly, I have attached a screenshot of the Capability Config section of the admin-cli client, if that is useful.

Thank you!

I just noticed that I do not have a “Home URL” assigned for the admin-cli client even though it is an OpenID Connect client (see attached screenshot). The account and account-console clients have associated URLs.

I wonder if this may be the issue, and if so what I can do to fix this issue.

Thank you!

SOLUTION

Issue solved by resetting password for the admin user. I was able to successfully obtain a token. Must have triggered something.