# Node.js oAuth - unsupported\_grant\_type on Step 4

**URL:** <https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839>\
**Category:** Friendly Help\
**Created:** [October 31, 2020, 11:51pm UTC](https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839 "2020-10-31T23:51:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardK](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@RichardK](https://www.patreondevelopers.com/u/RichardK)\
**Post date:** [October 31, 2020, 11:51pm UTC](https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839/1 "2020-10-31T23:51:30Z")

</div>

Hello,

I am trying to implement the oAuth2 flow using Node.js to enable my users to connect their Patreon account to my site to prove they are indeed paying. I am following the oAuth implementation guide but at step 4 the only response I get from the API is

`{ error: 'unsupported_grant_type' }`

My code is

```
const response = await fetch("https://www.patreon.com/api/oauth2/token", {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-encoded" },
    body:
      "code=" +
      code +
      "&grant_type=authorization_code&client_id=" +
      PA_APP_ID +
      "&client_secret=" +
      PA_APP_SECRET +
      "&redirect_url=" +
      PA_CALLBACK,
  });

```

All the variables are set correctly and according to the docs the required grant type is indeed “authorization\_code”. So … what am I doing wrong? I have done several other oAuth implementations and this is the only time an API gives me a headache.

Thanks, Richard

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [November 2, 2020, 4:26pm UTC](https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839/2 "2020-11-02T16:26:43Z")

</div>

Can you try adding a user-agent header to the call…

---

<div class="post-metadata">

**Author:** ![RichardK](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@RichardK](https://www.patreondevelopers.com/u/RichardK)\
**Post date:** [November 2, 2020, 10:20pm UTC](https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839/3 "2020-11-02T22:20:46Z")

</div>

I just tried that and it didn’t change anything, unfortunately.

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [November 6, 2020, 11:32pm UTC](https://www.patreondevelopers.com/t/node-js-oauth-unsupported-grant-type-on-step-4/3839/4 "2020-11-06T23:32:01Z")

</div>

Are you using a v2 client? Are you calling v2 endpoints?
