# Cannot get an access token - unknown grant type

**URL:** <https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362>\
**Category:** APIs & Integrations\
**Created:** [September 21, 2017, 9:11am UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362 "2017-09-21T09:11:56Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [September 21, 2017, 9:11am UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/1 "2017-09-21T09:11:56Z")

</div>

Hi,

I am trying to get access token for a user, but I keep receiving `"status":"BAD_GRANT_TYPE","message":"missing or unknown grant type"`. I have tried encoding query params or passing them as one json param, but nothing worked.

```auto
payload = {
 'grant_type': 'authorization_code',
 'client_id': 'f6***',
 'client_secret': 'f2***',
 'redirect_uri': 'https://sc***/',
 'code': '5f***'
}

```

```auto
requests.post('https://api.hubapi.com/oauth/v1/token?', params=payload)

```

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [September 21, 2017, 1:14pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/2 "2017-09-21T13:14:18Z")

</div>

[@esthom](https://community.hubspot.com/u/esthom) Are you setting your content-type in the headers? Should be

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

Sometimes not having the correct content-type can throw off a server trying to read your request.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 27, 2017, 3:55pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/3 "2017-10-27T15:55:56Z")

</div>

[@pmanca](https://community.hubspot.com/u/pmanca) I seem to be having the same issue. Not sure why however. the header on postman is as you describe it along with the body data.

header image: [Screen Shot 2017 10 27 at 18 53 25 hosted at ImgBB — ImgBB](https://ibb.co/bOVrAm)  
body image: [Screen Shot 2017 10 27 at 18 53 38 hosted at ImgBB — ImgBB](https://ibb.co/d6Rni6)

Any ideas would be greatly appreciated.

thx

---

<div class="post-metadata">

**Author:** ![3PETE](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/3pete/32/61905_2.png) [@3PETE](https://community.hubspot.com/u/3PETE)\
**Post date:** [November 1, 2017, 6:17pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/4 "2017-11-01T18:17:23Z")

</div>

[@sphot](https://community.hubspot.com/u/sphot) Can you send along the full image of your body?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [August 15, 2018, 2:25pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/5 "2018-08-15T14:25:06Z")

</div>

Hi, I’m having the same problem with Postman, how could you solve it?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 10, 2018, 10:27am UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/6 "2018-12-10T10:27:42Z")

</div>

But not working for me even after chnaging the order as follows:  
grant\_type=authorization\_code  
&client\_id=xxx  
&client\_secret=xxx  
&redirect\_uri=[https://api.hubapi.com/contacts/v1/lists/all/contacts/all](https://api.hubapi.com/contacts/v1/lists/all/contacts/all)  
&code=code\_here

And adding " `Content-Type: application/x-www-form-urlencoded;charset=utf-8`"

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/6/8694accc33760789e210ff21be9b186fc6f8513f.png)

![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/9/79c58e289c69778d58001f9287c88abf70ee24c6.png) esthom:

> having the correct content-type can throw off a server trying to read your request.

---

<div class="post-metadata">

**Author:** ![samarr](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/samarr/32/99782_2.png) [@samarr](https://community.hubspot.com/u/samarr)\
**Post date:** [August 19, 2020, 12:28pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/7 "2020-08-19T12:28:02Z")

</div>

I am facing this problem, even though supplying the required params in the header and request body respectively as follows:

![30454i896BD2170251BD76.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/6/06e2ea8f004083f4b563331bc4e650d9b1b300ef.jpeg)  
ContentHeader

 ![30455i2CDCF88034C363DF.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/a/ca641784f171289b44863c833e922cd9609e2965.jpeg)  
Body

Here’s the error I face:

 ![30456i87A2CC56223C2BA9.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/9/199fb1ea49116bd29fb5d08e8643a05ddcd6f262.jpeg)  
Error Window

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 9, 2017, 3:29pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/8 "2017-10-09T15:29:41Z")

</div>

Thanks [@pmanca](https://community.hubspot.com/u/pmanca), that worked fine!

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 10, 2018, 2:13pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/9 "2018-12-10T14:13:06Z")

</div>

Welcome, [@brij](https://community.hubspot.com/u/brij).

Per [this documentation](https://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens), you must include `grant_type`, `client_id`, `client_secret`, `redirect_uri`, and `code` in the _ **request body** _.

You are trying to include those parameters as headers, but the only header should be `Content-Type: application/x-www-form-urlencoded;charset=utf-8`.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 10, 2018, 2:44pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/10 "2018-12-10T14:44:02Z")

</div>

Not it says "{  
“status”: “BAD\_CLIENT\_ID”,

“message”: “missing or unknown client id”,"

I think it worked now I have to get new client id.

But the same client id was used to get the code.

---

<div class="post-metadata">

**Author:** ![yan\_hero\_power](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/yan_hero_power/32/29572_2.png) [@yan\_hero\_power](https://community.hubspot.com/u/yan_hero_power)\
**Post date:** [September 21, 2019, 6:26am UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/11 "2019-09-21T06:26:17Z")

</div>

Hi, I am encountering similar issues with the curl response. In POSTMAN I am able to get a successful response, but when I replicate the settings in PHP with cURL, I am getting a “BAD\_GRANT\_TYPE” response.

Content Type should be set properly in the request. But I notice in the curl response, it shows content\_type = application/json, is that correct?

Do you have any suggestions? Thanks

 ![Screen Shot 2019-09-21 at 1.19.42 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/2/264a221c67e264790ea9f49d45b5c398691efac3.png)

 ![Screen Shot 2019-09-21 at 1.22.46 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/e/de1cb57f497c6f722db25bee0923365b9b2377e0.png)

 ![Screen Shot 2019-09-21 at 1.24.10 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/b/0bba47967b4a20a427520b72a4702e736ea79ee3.png)

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 11, 2018, 3:07pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/12 "2018-12-11T15:07:09Z")

</div>

Hi, [@brij](https://community.hubspot.com/u/brij).

Are you still experiencing this error? I was unsure whether your last post said you got it working.

The `client_id` you should use is located in your app settings. If you need help finding this, please share your developer Hub ID and app ID.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 12, 2018, 12:34pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/13 "2018-12-12T12:34:14Z")

</div>

It worked now, please remove my last response.

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 12, 2018, 3:09pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/14 "2018-12-12T15:09:39Z")

</div>

Glad to hear it, [@brij](https://community.hubspot.com/u/brij)! I’ve deleted the post you requested.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 12, 2018, 4:44pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/15 "2018-12-12T16:44:42Z")

</div>

[@Isaac\_Takushi](https://community.hubspot.com/u/isaac_takushi) Thanks a lot!

---

<div class="post-metadata">

**Author:** ![AAbdullah6](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@AAbdullah6](https://community.hubspot.com/u/AAbdullah6)\
**Post date:** [April 3, 2024, 2:29pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/16 "2024-04-03T14:29:03Z")

</div>

Looking for the same answer for my site.i am running a social grant company website that hosted on wordpress and i want to run it multiple network.

---

<div class="post-metadata">

**Author:** ![julia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/julia/32/154_2.png) [@julia](https://community.hubspot.com/u/julia)\
**Post date:** [June 30, 2026, 3:51pm UTC](https://community.hubspot.com/t/cannot-get-an-access-token-unknown-grant-type/11362/17 "2026-06-30T15:51:00Z")

</div>

Opened on June 30, 2026, 3:51pm UTC


