First of all I am very new to Keycloak and excuse me if something I am asking might be wrong.
I have installed the Keycloak server and I can access the Web UI for the same using:
My requirement is to validate a realm user by passing it to k Keycloak API and to get the token from there in response, and then pass this token for my other Web API calls.
But I was not able to find a simple guide on how I can do this...
UPDATE:
USING UI from KEYCLOAK
:
So far now:
I am able to create a
realm
: e.g:DemoRealm
Under the
Realm
I have created the client: e.g:DemoClient
Under the client I have created the user: e.g:
DemoUser
USING POSTMAN
:
I am also able to successfully get the token using
http://localhost:8080/auth/realms/DemoRelam/protocol/openid-connect/token
POST:
{
"grant_type": "client_credentials",
"username": "",
"password": "",
"client_secret":"",
"client_id":"DemoClient"
}
In response I am getting the token.
{
"access_token": "eyJhbGciOiJSUzI1NiIsINVSHGhepnDu13SwRBL-v-y-04_6e6IJbMzreZwPI-epwdVPQe-ENhpvms2WdGM_DmgMLZ8YQFS4LDl9R7ZHT8AgXe-WCFV6OFkA7zvdeFwQ4kVVZE0HlNgHgoi4DrgMfwwz_ku1yJNJP3ztTY1nEqmA",
"expires_in": 300,
"refresh_expires_in": 1800,
"refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJRRnB5YlloMGVEektIdlhOb3JvaFUxdlRvWVdjdP3vbfvk7O0zvppK9N4-oaUqZSr0smHv5LkuLDQYdPuxA",
"token_type": "bearer",
"not-before-policy": 0,
"session_state": "bb1c586a-e880-4b96-ac16-30e42c0f46dc"
}
Furthermore I was diving into more details and found this API guide:
http://www.keycloak.org/docs-api/3.0/rest-api/index.html#_users_resource
In this guide it's mentioned that I can get the users for the realm using Get users Returns a list of users, filtered according to query parameters
GET /admin/realms/{realm}/users
But when I am using POSTMAN
to get the users I am getting 403 error code. I am passing the same token as on authentication which I got in the earlier step.
http://localhost:8080/auth/admin/realms/DemoRelam/users
Can anyone please guide me?