Keycloak Missing form parameter: grant_type Keycloak Missing form parameter: grant_type java java

Keycloak Missing form parameter: grant_type


You should send your data in a POST request with Content-Type header value set to application/x-www-form-urlencoded, not json.


With Curl

curl -X POST \http://localhost:8080/auth/realms/api-gateway/protocol/openid-connect/token \-H 'Accept: */*' \-H 'Accept-Encoding: gzip, deflate' \-H 'Cache-Control: no-cache' \-H 'Connection: keep-alive' \-H 'Content-Length: 73' \-H 'Content-Type: application/x-www-form-urlencoded' \-H 'Cookie: JSESSIONID=F8CD240FF046572F864DC37148E51128.a139df207ece;   JSESSIONID=65D31B82F8C5FCAA5B1577DA03B4647C' \-H 'Host: localhost:8080' \-H 'Postman-Token: debc4f90-f555-4769-b392-c1130726a027,d5087d9f-9253-48bd-bb71-fda1d4558e4d' \-H 'User-Agent: PostmanRuntime/7.15.2' \-H 'cache-control: no-cache' \-d 'grant_type=password&client_id=api-gateway&username=admin&password=temp123'

By Postman(Select x-www-form-urlencoded option for parameters)

enter image description here


For those having problems with curl the curl command is as follows

curl -d "client_secret=<client-secret>" -d "client_id=<client-id>" -d "username=<username>" -d "password=<password>" -d "grant_type=password" "http://localhost:8080/auth/realms/<realm-name>/protocol/openid-connect/token"

The curl command works without the Content-Type header.