Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to log in to Keycloak Admin WS

Tags:

rest

keycloak

I need to configure realms in Keycloak by the Admin WS accessible at the path

http://KeycloakServer:8081/auth/admin/realms

So in Postman I run the following request

URL: http://KeycloakServer:8081/auth/admin/realms

Method: POST

Body:

{
    "enabled": true,
    "id": "TestRealm",
}

I get a 401 Unauthorized response, so I think it is necessary to authenticate to the Admin WS. But in the docs I cannot find any information about the type of authentication required and the syntax. Do you know how to authenticate to the Keycloak WSs?

Thank you

like image 762
gvdm Avatar asked Oct 27 '15 10:10

gvdm


1 Answers

Do a POST request to https://hostname:8080/auth/realms/master/protocol/openid-connect/token

Sets the Content-Type to application/x-www-form-urlencoded

and put the following in the body:

username=<username>&password=<password>&client_id=admin-cli&grant_type=password
like image 183
Andrea Scarpino Avatar answered Sep 22 '22 04:09

Andrea Scarpino