Getting Unsupported Media Type Error while geting token

rohit95
Member
 

hello,

I am creating OAuth in our application I am able to get code plz ref docs: https://developers.hubspot.com/docs/api/oauth-quickstart-guide 

 

I am stuck on step 4 :

Exchange authorization code for tokens

below Is java spring boot code for get token API call.

 

Screenshot from 2020-07-16 18-09-00.png

0 Upvotes
3 Replies 3
WendyGoh
HubSpot Moderator

Hey @rohit95,

 

Looking at the code, I believe this is likely because your team is using content-type: application/json however, the content type for the get OAuth 2.0 access and refresh tokens endpoint is application/x-www-form-urlencoded. As documented here: Get OAuth 2.0 access and refresh tokens

 

Could you either remove the header or change the header from application/json to application/x-www-form-urlencoded and see if it works? 

0 Upvotes
emilyfarrar
Participant

We are experiencing the same issue. We first experienced a media type error and used the direction from this post to resolve it by adding the JSON application content type. Now we're getting the unknown or missing grant type error. 

 

 

0 Upvotes
WendyGoh
HubSpot Moderator

Hey @emilyfarrar

 

As mentioned on this dev forum thread, could you try the following content type header and see if it works?

 

Content-Type: application/x-www-form-urlencoded;charset=utf-8

0 Upvotes