# Reddit API Oauth2

**URL:** <https://community.parabola.io/t/reddit-api-oauth2/1264>\
**Category:** Ask a question\
**Tags:** Using-APIs\
**Created:** [November 6, 2020, 10:16pm UTC](https://community.parabola.io/t/reddit-api-oauth2/1264 "2020-11-06T22:16:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Schaeffer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sebastian_schaeffer/32/967_2.png) [@Sebastian\_Schaeffer](https://community.parabola.io/u/Sebastian_Schaeffer)\
**Post date:** [November 6, 2020, 10:16pm UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/1 "2020-11-06T22:16:51Z")

</div>

Hi guys,

could anyone outline the best way to connect Parabola to the Reddit API?

I’ve been playing around with it but I keep getting 401 errors for some reason.

I guess there is some problem with the authentication but I already tried using basic authentication but I am still getting the same error.

I would really appreciate the help, thanks!

Sebastian

---

<div class="post-metadata">

**Author:** ![sachi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sachi/32/10_2.png) [@sachi](https://community.parabola.io/u/sachi)\
**Post date:** [November 7, 2020, 1:01am UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/2 "2020-11-07T01:01:20Z")

</div>

Hey @Sebastian_Schaeffer - I’m consulting [these docs here](https://github.com/reddit-archive/reddit/wiki/OAuth2), but let me know if you’re looking at something else, they might have some newer docs I’m not finding.

First, make sure to select “OAuth 2.0” from the Authentication dropdown.

**1. Authorization**  
Authorization Request URL:  
`https://www.reddit.com/api/v1/authorize?client_id=your_client_id&response_type=code&redirect_uri=https%3A%2F%2Fparabola.io%2Fapi%2Fsteps%2Fgeneric_api%2Fcallback&duration=permanent&scope=read&state=123456789`

Make sure to edit `your_client_id` with your client id.

 ![Screen Shot 2020-11-06 at 4.54.23 PM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/a1cf0f4bb94e3d71f82b73a775148a54cfa8567a.png)

**2. Access Token**  
Access Token Request URL:  
`https://www.reddit.com/api/v1/access_token`  
Access Token Method: `POST`  
For the Access Token Request Body:  
grant\_type = `authorization_code`  
redirect\_url = `https://parabola.io/api/steps/generic_api/callback`

 ![Screen Shot 2020-11-06 at 4.57.29 PM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/122add5e1862d7f657149768db5c9cd66f960270.png)

**3. Refresh Token**  
Refresh Token Request URL: `https://www.reddit.com/api/v1/access_token`  
Refresh Token Method: POST  
grant\_type = `refresh_token`

 ![Screen Shot 2020-11-06 at 4.58.26 PM](https://us1.discourse-cdn.com/flex020/uploads/parabola/original/1X/60e56d0f0f047e420f3086e8cae038a4219a54cc.png)

Let me know how that goes. If you’re encountering an error, reply back with a screenshot (with private info blurred out) and we can take a closer look!

---

<div class="post-metadata">

**Author:** ![Sebastian\_Schaeffer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sebastian_schaeffer/32/967_2.png) [@Sebastian\_Schaeffer](https://community.parabola.io/u/Sebastian_Schaeffer)\
**Post date:** [November 7, 2020, 7:30am UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/3 "2020-11-07T07:30:24Z")

</div>

> [@sachi](#):
>
> [https://www.reddit.com/api/v1/access\_token](https://www.reddit.com/api/v1/access_token)

Hey Sachi,

thanks for this! After adding everything you wrote in your post I got this error:

> An error occurred during authorization: Access token URL returned a 429 when making a request for the access token. More data here: b’{“message”: “Too Many Requests”, “error”: 429}’

This happens right after the auth screen that reddit shows where it asks me if I want to give permission to read my posts etc.

After some googling it noticed that the API requires a user-agent so I added a user-agent header. Now I am getting this error:

> An error occurred during authorization: Access token URL returned a 401 when making a request for the access token. More data here: b’{“message”: “Unauthorized”, “error”: 401}’

I am not sure why this is happening…I tried adding an Authentication header like this: “basic clientid:secret” but that also didn’t work so now I am a bit lost 🙂 Any ideas?

thx!

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/daniel/32/732_2.png) [@daniel](https://community.parabola.io/u/daniel)\
**Post date:** [November 10, 2020, 2:33am UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/4 "2020-11-10T02:33:28Z")

</div>

Hi @Sebastian_Schaeffer,

Hm, this is a strange error message. We’ll need to take a moment to troubleshoot this on our end. OAuth2 can be tricky depending on the service you’re using.

In the meantime, would you try re-adding a custom header to the second step? The key should be `Authorization` and the value should be `Basic client_id:client_secret`. You may need to base64 encode your the part where it says `client_id:client_secret`.

To do that, insert your `client_id` and `client_secret` as you normally would. Then paste that string into [this site](https://www.base64encode.org/) and select encode. Grab that value and exchange that in your `Authorization` value.

Let me know if that provides different results, and we’ll keep looking into it on our end.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Schaeffer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/sebastian_schaeffer/32/967_2.png) [@Sebastian\_Schaeffer](https://community.parabola.io/u/Sebastian_Schaeffer)\
**Post date:** [November 10, 2020, 8:14am UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/5 "2020-11-10T08:14:37Z")

</div>

This actually got me one step further! So it must be the base64 encoding that was missing…my mistake. I thought parabola would take care of that.

Now I run into this error

> An error occurred during authorization: Access token URL returned a 400 when making a request for the access token. More data here: b’{“explanation”: “request contains duplicate parameter for oauth2: code”, “message”: “Bad Request”, “reason”: “OAUTH2\_DUPLICATE\_PARAMS”}’

Not really sure why these would be duplicate…

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex020/user_avatar/community.parabola.io/daniel/32/732_2.png) [@daniel](https://community.parabola.io/u/daniel)\
**Post date:** [November 11, 2020, 1:45am UTC](https://community.parabola.io/t/reddit-api-oauth2/1264/6 "2020-11-11T01:45:54Z")

</div>

Hey @Sebastian_Schaeffer,

Unfortunately, it looks like we won’t be able to connect to Reddit’s API via OAuth at the moment.

I attempted to authenticate a personal account by using the same steps listed above. Both a `User-Agent` header key and `Authorization` key with a base64 encoded `client_id` and `client_secret` were added to the request.

The same error code was returned to me also stating there were duplicate parameters within our JSON body. I’m not certain, but this may be linked to how Reddit generates a URL after the request is sent for an access token, causing a duplicative value along the way.

If we decide to update our OAuth module to connect with Reddit, we’ll be sure to let you know in the future!
