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, Reddit::Client is now Oauth only. From a user's perspective it can be considered the same as logging in was before, but with an additional username and password for the script.

Setting up a script is simple:

  1. Go to your apps page on reddit.com. It's located at https://www.reddit.com/prefs/apps. 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 are able to take actions on behalf of a user without the user's password, so they have a more complicated authentication process. Those kinds of apps are outside the scope of Reddit::Client-- it only supports script type apps.)

    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.

Here's a working example script. (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. 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 of other differences with Oauth:

  • You get 60 requests per minute instead of 30.
  • There are no more cookies and modhashes. This is mostly of interest to API wrapper developers, but as a user, it means you don't need a session file anymore.