r/redditdev 1d ago

403 error when attempting to access a JSON feed with bearer authorization? Reddit API

I'm attempting to make the following get request to a private moderator feed, the URL for which I obtained through https://old.reddit.com/prefs/feeds.

get_request:
    URL: "https://old.reddit.com/r/mod/about/modqueue/.json?feed=*********&user=*********"
    headers:
        User-Agent: "pipedream/1"
        Authorization: "Bearer {{bearer_token}}}"

My authorization for this request is a bearer token that the code obtains from https://www.reddit.com/api/v1/access_token in a previous step. A new bearer token is requested every time the code runs, so the token expiring isn't a concern.

However, the request continuously fails with a status code 403. This code worked perfectly fine up until about 3 months ago, after which this error began occuring. The bearer token I'm using is also the same token that's being outputted from my POST request to https://www.reddit.com/api/v1/access_token, which returns successfully with the bearer token every time.

Did something change with Reddit's API in the past few months? Does anyone know any troubleshooting steps I could take to try and fix this?

Note: I'm not currently working with Python. This is a raw GET request that I'm making through a Pipedream workflow.

Here's the error response body, if it helps:

<!doctype html>
     <html>
  <head>
    <title>Blocked</title>
    <style>
      body {
          font: small verdana, arial, helvetica, sans-serif;
          width: 600px;
          margin: 0 auto;
      }

      h1 {
          height: 40px;
          background: transparent url(//www.redditstatic.com/reddit.com.header.png) no-repeat scroll top right;
      }
    </style>
  </head>
  <body>
    <h1>whoa there, pardner!</h1>

<p>Your request has been blocked due to a network policy.</p>

<p>Try logging in or creating an account <a href=https://www.reddit.com/login/>here</a> to get back to browsing.</p>

<p>If you're running a script or application, please register or sign in with your developer credentials <a href=https://www.reddit.com/wiki/api/>here</a>. Additionally make sure your User-Agent is not empty and is something unique and descriptive and try again. if you're supplying an alternate User-Agent string,
try changing back to default as that can sometimes result in a block.</p>

<p>You can read Reddit's Terms of Service <a href=https://www.reddit.com/wiki/api/>here</a>.</p>

<p>if you think that we've incorrectly blocked you or you would like to discuss
easier ways to get the data you want, please file a ticket <a href=https://support.reddithelp.com/hc/en-us/requests/new?ticket_form_id=21879292693140>here</a>.</p>

<p>when contacting us, please include your ip address which is: <strong>3.84.50.106</strong> and reddit account</p>
  </body>
</html>
3 Upvotes

1

u/Watchful1 RemindMeBot & UpdateMeBot 20h ago

Requests to the api have to be to oauth.reddit.com, without the .json.

1

u/Fluffy__Pancake 18h ago

I've tried making requests to https://oauth.reddit.com/api/v1/me and it also fails for me even though I successfully get the access token

1

u/Fluffy__Pancake 18h ago edited 18h ago

Edit: just tested from Python and it works fine when trying https://oauth.reddit.com/r/funny/top.json?t=week as well as Javascript from the browser console (in incognito mode) but it still fails from my Node server.

So maybe this is some issue with how Node is constructing the request??? Although my Node server is able to make requests to other APIs just fine so I really don't understand what could be going on. Also don't know why you're having an issue with Pipedream (unless it's a Node server)

I just started to try to use the Reddit API and I'm having the same issue. I can successfully get the access token but any request I make returns a 403. I also am requesting a new token for each request and have tried to research a solution but can't figure it out.

I saw somewhere that it could be because of your account? I'm not sure why but I remember someone saying they made a new account and were able to get it to work that way.

But the weird thing is I can make the request from Postman or even from an incognito tab on my browser (so without authorization using reddit.com as the url base) and the requests work, but when I try to do so from my Node server, I get a 403.

1

u/thesanemansflying 16h ago

Had this same exact issue with Node, and only from my node server as well. But maybe will change how I'm coding it or make a new app. Or maybe I'll learn python and just use python.

1

u/Fluffy__Pancake 15h ago

Ok I figured out that you can send requests through Google translate for the API endpoints of public information. 

Like I even got the “regular” https://www.reddit.com/r/funny/top.json?t=week to work through that. If you go to the website there’s a mode to enter a URL and it seems to send back the JSON result just fine