Reddit - Oauth Scripts for Dummies


Oauth is now the preferred way to talk to Reddit’s API, and while the old methods still work (sort of, for now), they’ve become unpredictable. Since the devs have said that non-Oauth access will eventually be throttled or blocked outright, switching to Oauth now is a good idea.

Luckily it’s very simple for scripts.

  1. Go to your apps page on It’s located at Click the “create an app” button at the bottom.

  2. Enter a name for the app and optionally a description. For the app type choose script. The other two types are for applications meant for public consumption— for example, a mobile app like Reddit is Fun. Those apps log in as you but don’t get access to your password, so they have a more complicated authentification process. Those apps are outside the scope of this guide— this just covers a basic script type app.

    The about url can be left blank and the redirect URI is required but can be any valid web address. (It’s only used for the other app types.)

    When you’re done it should look something like this:

  3. After saving your app will appear in your list of apps. Clicking “edit” at the app’s bottom left will present you with something like this:

    Your client_id is at the top, under the app name and type. secret is below that, the first field in the app info.

    Think of them as your app’s username and password. As a user, that’s all you really need to know about Oauth if you don’t feel like learning more: your apps now have their own username and password in addition to your own.

  4. Use your client_id and secret in your script. The previous step was actually the last one in setting up an app, but here’s a working example script, using Perl and Reddit::Client. (The credentials are fake, obviously.)

    use Reddit::Client;
    my $reddit = new Reddit::Client(
                    user_agent      => "test /u/earth-tone",
                    client_id       => "DFhtrhBgfhhRTd",
                    secret          => "KrDNsbeffdbILOdgbgSvSBsbfFs",
                    username        => "reddit_username",
                    password        => "reddit_password"                   );
    my $me = $reddit->me();
    print "You've got mail!" if $me->{has_mail};

Only accounts that have permission can use the app. You can see which accounts have permission on the upper right. To add an account just type in the account username and press enter; no verification is done and they don’t have to accept it or anything. While you do have to do that manually, it shouldn’t be a problem since script-type apps are only intended for you and your robot army. If the public is authenticating through your app, you need to use one of the other app types.

A couple more good reasons to switch to Oauth:

  • 60 requests per minute instead of 30. But, like I mentioned before, that 30 has become 30ish and will eventually become zero.
  • No more dealing with cookies and modhashes. This is mostly of interest to API wrapper developers, but for me personally, cookies and modhashes always felt messy, so I was glad to be rid of them.



There are currently no comments on this article.


Enter your comment below. Fields marked * are required. You must preview your comment first before finally posting.

← Older Newer →