# Request Access Token with content-type application/json

**URL:** <https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621>\
**Category:** Miscellanaeous\
**Created:** [June 16, 2021, 2:55pm UTC](https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621 "2021-06-16T14:55:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steph](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/steph/32/3363_2.png) [@steph](https://forum.keycloak.org/u/steph)\
**Post date:** [June 16, 2021, 2:55pm UTC](https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621/1 "2021-06-16T14:55:36Z")

</div>

Hello,  
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

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [June 16, 2021, 3:51pm UTC](https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621/2 "2021-06-16T15:51:43Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![steph](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/steph/32/3363_2.png) [@steph](https://forum.keycloak.org/u/steph)\
**Post date:** [June 17, 2021, 7:19am UTC](https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621/3 "2021-06-17T07:19:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steph](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/steph/32/3363_2.png) [@steph](https://forum.keycloak.org/u/steph)\
**Post date:** [July 6, 2021, 7:14am UTC](https://forum.keycloak.org/t/request-access-token-with-content-type-application-json/9621/4 "2021-07-06T07:14:58Z")

</div>

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
