APIs & Integrations

coffeeocean
Participant

"missing or unknown grant type" error during /oauth/v1/token POST request

I was converting to oauth2 and was able to get the “code” after user sign-in. However when I made POST request to /oauth/v1/token to get the tokens by the “code”, I ran into the following HTTP 400 error:

{“error”:“invalid_request”,“error_description”:“missing or unknown grant type”}

Below is my POST body/payload (scrambled):

client_id=36BBBBBB-CCCC-DDDD-EEEE-2129FFFFFFFF&client_secret=SSSSSSSSSSSSSSSSS&grant_type=authorization_code&redirect_uri=https://localhost:8443/myredirect.html&code=31AAAAAAA-BBBB-4efe-CCCC-e82c34DDDDDD

I tried rearranged the order of the parameters in the payload, but it made no difference. I’m pretty sure grant_type=authorization_code the same I copied from doc (http://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens). But it still complains it’s missing/invalid.

Did I miss anything? Thanks!

0 Upvotes
3 Replies 3
salty_stephen
Contributor | Elite Partner
Contributor | Elite Partner

"missing or unknown grant type" error during /oauth/v1/token POST request

Hi @coffeeocean,

From what I can tell, the payload looks correct.

What is the full URL that you are POSTing to?

https://api.hubapi.com/oauth/v1/token (notice that for oAuth the base URL is: https://api.hubapi.com and not https://app.hubspot.com)

The only other thing that I can think of would be a problem with your app permissions.

0 Upvotes
coffeeocean
Participant

"missing or unknown grant type" error during /oauth/v1/token POST request

I indeed posted to the right domain. Full URL is: https://api.hubapi.com/oauth/v1/token.

What do you mean by app permissions? Did you mean “scope”, which I set to be “scope=contacts” when redirecting the user to sign in at https://app.hubspot.com/oauth/authorize.

Thanks!

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

"missing or unknown grant type" error during /oauth/v1/token POST request

Hi @coffeeocean

As @Stephen_Yager mentioned, the payload does look correct, but you should only be getting that error message for problems specific to the grant_type field (any problems with the other fields return errors specific to the field with the problem).

If you’re still seeing that error, can you message me directly and send me the full payload that you’re using so I can take a look at your specific data?

0 Upvotes