Reddit::Client supports two types of authentication: "script"-type, which is intended for single users, and "web"-type, for applications that the public at large can use. (They allow any user to authorize the app to take actions on their behalf.) Unless you're developing an application for public consumption, "script"-type is what you're looking for.

While Reddit::Client supports "web"-type apps, we don't have a tutorial for setting them up yet, so getting it to work is left as an exercise for the reader. The functions you will need, however, such as get_refresh_token are documented in Main Methods. Documentation for the entire "web"-type flow can be found at https://github.com/reddit-archive/reddit/wiki/OAuth2.

Setting up a "script"-type app

  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 about url and redirect URI can be any valid web address. Feel free to copy and paste whatever's in your address bar; they aren't used.

    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. You can think of them as your app's username and password.

  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/username",
    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.