line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12524
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
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.000004'; |
6
|
1
|
|
|
1
|
|
379
|
use Mojo::Base qw/Mojolicious::Plugin::Web::Auth::OAuth2/; |
|
1
|
|
|
|
|
6519
|
|
|
1
|
|
|
|
|
4
|
|
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.000004 |
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 => 'www.reddit.com', |
42
|
|
|
|
|
|
|
path => '/api/v1/access_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, $extra ) = @_; |
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, $extra ) = @_; |
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. Your C will be included in the C<$extra> arg as seen |
88
|
|
|
|
|
|
|
above. For example, C<$extra> may look like the following: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
expires_in => 3600, |
92
|
|
|
|
|
|
|
refresh_token => 'seekrit_token', |
93
|
|
|
|
|
|
|
scope => |
94
|
|
|
|
|
|
|
'edit flair history identity modconfig modflair modlog modposts modwiki mysubreddits privatemessages read report save submit subscribe vote wikiedit wikiread', |
95
|
|
|
|
|
|
|
token_type => 'bearer', |
96
|
|
|
|
|
|
|
}, |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Olaf Alders |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Olaf Alders. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |