# OAuth Step 4 issue

**URL:** https://www.patreondevelopers.com/t/oauth-step-4-issue/1988
**Category:** Uncategorized
**Created:** [June 23, 2019, 6:35pm UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988 "2019-06-23T18:35:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tpeschke](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tpeschke](https://www.patreondevelopers.com/u/tpeschke)
#### Post date: [June 23, 2019, 6:35pm UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/1 "2019-06-23T18:35:24Z")

</div>

I’ve been trying to figure out this series of errors for awhile now and the errors in the docs are just _incredibly unhelpful_ with how vague they are.

Here’s my code (I’m using NodeJS):  
function handleOAuthRedirectRequest (req, res) {  
let {code} = req.query  
axios.post(`https://www.patreon.com/api/oauth2/token?code=${code}&grant_type=authorization_code&client_id=${patreonId}&client_secret=${patreonSecret}&redirect_uri=${redirect}`, {}, {headers: {‘Content-Type’: ‘application/x-www-form-urlencoded’}})  
.then(result =\> console.log(result))  
.catch(e=\>console.log(e))  
}

And I’m getting a 401 { error: ‘invalid\_grant’ }.

When I change it to …&grant\_type=\_code&client\_id…  
I get 400 { error: ‘unsupported\_grant\_type’ }

I’ve also tried pushing everything through in the body and that didn’t work either.

What do these errors mean? What am I doing wrong?

---

<div class="post-metadata">

### Author: ![evy](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@evy](https://www.patreondevelopers.com/u/evy)
#### Post date: [July 2, 2019, 6:35pm UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/2 "2019-07-02T18:35:35Z")

</div>

Peculiar! I don’t see any issue on first glance.

In the 401 response, there should a request id. Can you send that our way, so we can look into the request to see more details around what’s going on?

---

<div class="post-metadata">

### Author: ![tpeschke](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tpeschke](https://www.patreondevelopers.com/u/tpeschke)
#### Post date: [July 3, 2019, 12:01am UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/3 "2019-07-03T00:01:06Z")

</div>

It is.

So, the error isn’t a 401 - it’s 400, so there’s something about the request that’s bad but I’m not sure what it is and both errors I’m getting aren’t helpful

---

<div class="post-metadata">

### Author: ![evy](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@evy](https://www.patreondevelopers.com/u/evy)
#### Post date: [July 3, 2019, 12:14am UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/4 "2019-07-03T00:14:49Z")

</div>

> [@tpeschke](#):
>
> I’m getting a 401 { error: ‘invalid\_grant’ }.

So you’re saying this one is actually a 400? Is there a request id in the response body?

---

<div class="post-metadata">

### Author: ![tpeschke](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tpeschke](https://www.patreondevelopers.com/u/tpeschke)
#### Post date: [July 3, 2019, 2:43pm UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/5 "2019-07-03T14:43:34Z")

</div>

Yeah, that’s correct - I mistyped and it should be 400.

Are you talking about what’s underlined in red here:

 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/patreondevelopers/original/1X/de744da271295a83ddc32e989380c07a79b59621.png)

Because the body of the response object I’m getting back only has data: {error: ‘unsopported\_grant\_type’}

---

<div class="post-metadata">

### Author: ![tpeschke](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tpeschke](https://www.patreondevelopers.com/u/tpeschke)
#### Post date: [July 22, 2019, 7:01pm UTC](https://www.patreondevelopers.com/t/oauth-step-4-issue/1988/6 "2019-07-22T19:01:31Z")

</div>

Nothing yet, huh? Must be quite an issue to take more than 2 weeks to fix
