I have tried to access the keycloak API from the postman. but it is showing 400 bad request.
I was calling api in the below format.
http://{hostname}:8080/auth/realms/master/protocol/openid-connect/token?username=admin&password=admin&client_id=admin-cli&grant_type=password
In the headers I have set the content_type as application/x-www-form-urlencoded
I am getting the response as below.
{
"error": "invalid_request",
"error_description": "Missing form parameter: grant_type"
}
Can any one help me.Any help will be appreciated. thanks in advance
A bit late for this question, but you did ask about postman and not curl.
So you have to put the options in x-www-form-urlencoded
The URL you are using is to obtain the token.
The token request should be a POST call, the request you post is a GET request. Below a CURL example about how to request the access_token
curl -X POST \
http://{hostname}:8080/auth/realms/{realm}/protocol/openid-connect/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=admin&password=admin&grant_type=password&client_id=admin-cli'
You call API through POST client
URL - http://localhost:8080/auth/realms/Demo/protocol/openid-connect/token
So here in above url i am using Demo
as my realm instead of master
.
ContentType - "Content-Type":"application/x-www-form-urlencoded"
Params:
{
"client_secret" : "90ec9638-7647-4e65-ad20-b82df3341084",
"username" : "ankur",
"password" : "123456",
"grant_type" : "password",
"client_id": "app-client"
}
Set Header as below
Data Need to be passed as shown below