Request Access Token with content-type application/json

I’m new to keycloak, we’re starting a new projet and all worked fine after our tests.
Now we 're starting our tests with a partner and we have a problem with the content-type of the request to the access token.

Normally the access token request send cliend_id , client_secret in parameters of POST and content type is application/x-www-form-urlencoded .
Our partner send the request in json format and keycloak respond a 415 http error ( which is normal .) .

I read the rfc and many examples on the web and all the time, the content-type application/x-www-form-urlencoded is used .

Is there official recommandations not to send request on access token in json format ?
Is there a way ton configure keycloak to accept access token request in json format ?

Thank you for your help

Using the AuthCode flow in OIDC/OAuth2 requires to use sending form parameters as POST request, as you already read in the specs. That’s because the AuthCode flow is bound to a browser flow with several request/responses and redirects.

If you want to get an access token from an API/service, you can use the “Resource Owner Credential Flow” - in Keycloak called “Direct Grant”.
BUT: This is just for getting the tokens, with this approach you can’t make any benefits from SSO, as there are no cookies set/evaluated! Also, this flow is considered less secure!

1 Like

Thank you for you response .
Their message is sent in POST method but in json like this


“client_id”: “xxxxx”,

“client_secret”: “xxxxxxxxxxxxxxxxxx”,

“grant_type”: “xxxxxxxxxxxxxx”


i will try to make them change the way they call us to retrieve the access token

I tried to convaince them to change their content type to application/x-www-form-urlencoded for the request access token but they replied me this will impact others customers so it’s impossible on their side.
Do you have more information in the documentation to change the way keycloak accept access token made in json content type ? I didn"t find how to do in administration and documentation.

The error i have is " {“error”:“RESTEASY003065: Cannot consume content type”}

Thank you