File Coverage

blib/lib/Mojolicious/Plugin/Web/Auth/Site/Reddit.pm
Criterion Covered Total %
statement 9 10 90.0
branch n/a
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 15 80.0


line stmt bran cond sub pod time code
1 1     1   12915 use strict;
  1         2  
  1         22  
2 1     1   3 use warnings;
  1         1  
  1         48  
3              
4             package Mojolicious::Plugin::Web::Auth::Site::Reddit;
5             $Mojolicious::Plugin::Web::Auth::Site::Reddit::VERSION = '0.000002';
6 1     1   411 use Mojo::Base qw/Mojolicious::Plugin::Web::Auth::OAuth2/;
  1         6750  
  1         3  
7              
8             has access_token_url => 'https://www.reddit.com/api/v1/access_token';
9             has authorize_header => 'bearer ';
10             has authorize_url => 'https://www.reddit.com/api/v1/authorize';
11             has response_type => 'code';
12             has user_info => 1;
13             has user_info_url => 'https://oauth.reddit.com/api/v1/me';
14              
15 0     0 0   sub moniker { 'reddit' }
16              
17             1;
18              
19             =pod
20              
21             =encoding UTF-8
22              
23             =head1 NAME
24              
25             Mojolicious::Plugin::Web::Auth::Site::Reddit - Reddit OAuth Plugin for Mojolicious::Plugin::Web::Auth
26              
27             =head1 VERSION
28              
29             version 0.000002
30              
31             =head1 SYNOPSIS
32              
33             use URI::FromHash qw( uri );
34             my $key = 'foo';
35             my $secret = 'seekrit';
36              
37             my $access_token_url = uri(
38             scheme => 'https',
39             username => $key,
40             password => $secret,
41             host => 'api.fitbit.com',
42             path => 'oauth2/token',
43             );
44              
45             my $scope = 'identity,edit,flair,history,modconfig,modflair,modlog,modposts,modwiki,mysubreddits,privatemessages,read,report,save,submit,subscribe,vote,wikiedit,wikiread';
46              
47             # Mojolicious
48             $self->plugin(
49             'Web::Auth',
50             module => 'Reddit',
51             access_token_url => $access_token_url,
52             authorize_url =>
53             'https://www.reddit.com/api/v1/authorize?duration=permanent',
54             key => 'Reddit consumer key',
55             secret => 'Reddit consumer secret',
56             scope => $scope,
57             on_finished => sub {
58             my ( $c, $access_token, $access_secret ) = @_;
59             ...;
60             },
61             );
62              
63             # Mojolicious::Lite
64             plugin 'Web::Auth',
65             module => 'Reddit',
66             access_token_url => $access_token_url,
67             authorize_url =>
68             'https://www.reddit.com/api/v1/authorize?duration=permanent',
69             key => 'Reddit consumer key',
70             secret => 'Reddit consumer secret',
71             scope => $scope,
72             on_finished => sub {
73             my ( $c, $access_token, $access_secret ) = @_;
74             ...
75             };
76              
77             # default authentication endpoint: /auth/reddit/authenticate
78             # default callback endpoint: /auth/reddit/callback
79              
80             =head1 DESCRIPTION
81              
82             This module adds L support to
83             L.
84              
85             The default C allows only for temporary tokens. If you require
86             a refresh token, set your own C as in the example in the
87             SYNOPSIS.
88              
89             =head1 AUTHOR
90              
91             Olaf Alders
92              
93             =head1 COPYRIGHT AND LICENSE
94              
95             This software is copyright (c) 2017 by Olaf Alders.
96              
97             This is free software; you can redistribute it and/or modify it under
98             the same terms as the Perl 5 programming language system itself.
99              
100             =cut
101              
102             __END__