Can you call Keycloak /token with JSON body?


Is is possible to do a Keycloak /token API call and bass the body (username, password, grant_type, etc) as raw JSON (application/json)? When I pass the parameters as application/x-www-form-urlencoded things work fine. But when I pass the parameters as JSON then I get the below error.

“error”: “RESTEASY003065: Cannot consume content type”

  1. Do I have to change a setting so that Keycloak can accept a call to /token with a JSON body?
  2. If Keycloak cannot accept the parameters for a /token call as a JSON body, what is the reasoning behind that considering that when doing authentication from an API to Keycloak, the logical choide for the body is application/json?

Thank you in advance


Logical choice is implementation according to OIDC standard. That doesn’t saying anything about json support. Final: OpenID Connect Core 1.0 incorporating errata set 1