Reddit API Oauth2

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

Hey @Sebastian_Schaeffer - I’m consulting these docs here, 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.

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

3. Refresh Token
Refresh Token Request URL: https://www.reddit.com/api/v1/access_token
Refresh Token Method: POST
grant_type = refresh_token

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!

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 :slight_smile: Any ideas?

thx!

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 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.

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…

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!