line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LWP::Authen::OAuth2; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Make requests to OAuth2 APIs. |
4
|
|
|
|
|
|
|
our $VERSION = '0.18'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
351974
|
use 5.006; |
|
6
|
|
|
|
|
65
|
|
7
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
142
|
|
8
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
196
|
|
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
30
|
use Carp qw(croak confess); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
260
|
|
11
|
|
|
|
|
|
|
# LWP::UserAgent lazyloads these, but we always need it. |
12
|
6
|
|
|
6
|
|
2642
|
use HTTP::Request::Common; |
|
6
|
|
|
|
|
108154
|
|
|
6
|
|
|
|
|
382
|
|
13
|
6
|
|
|
6
|
|
3157
|
use JSON qw(encode_json decode_json); |
|
6
|
|
|
|
|
50235
|
|
|
6
|
|
|
|
|
31
|
|
14
|
6
|
|
|
6
|
|
4137
|
use LWP::UserAgent; |
|
6
|
|
|
|
|
127778
|
|
|
6
|
|
|
|
|
196
|
|
15
|
6
|
|
|
6
|
|
2640
|
use Module::Load qw(load); |
|
6
|
|
|
|
|
5511
|
|
|
6
|
|
|
|
|
35
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @CARP_NOT = map "LWP::Authen::OAUth2::$_", qw(Args ServiceProvider); |
18
|
6
|
|
|
|
|
312
|
use LWP::Authen::OAuth2::Args qw( |
19
|
|
|
|
|
|
|
extract_option copy_option assert_options_empty |
20
|
6
|
|
|
6
|
|
2855
|
); |
|
6
|
|
|
|
|
15
|
|
21
|
6
|
|
|
6
|
|
2708
|
use LWP::Authen::OAuth2::ServiceProvider; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
10246
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
5
|
|
|
5
|
0
|
2208
|
my ($class, %opts) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Constructing the service provider can consume my options. |
27
|
5
|
|
|
|
|
21
|
my $service_provider = LWP::Authen::OAuth2::ServiceProvider->new(\%opts); |
28
|
5
|
|
|
|
|
24
|
my $self |
29
|
|
|
|
|
|
|
= bless { |
30
|
|
|
|
|
|
|
service_provider => $service_provider |
31
|
|
|
|
|
|
|
}, $service_provider->oauth2_class(); |
32
|
5
|
|
|
|
|
23
|
$self->init(%opts, service_provider => $service_provider); |
33
|
5
|
|
|
|
|
18
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init { |
37
|
5
|
|
|
5
|
0
|
16
|
my ($self , %opts) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Collect arguments for the service providers. |
40
|
5
|
|
|
|
|
25
|
my $service_provider = $self->{service_provider}; |
41
|
5
|
|
|
|
|
23
|
my $for_service_provider = LWP::Authen::OAuth2::Args->new(); |
42
|
5
|
|
|
|
|
9
|
my %is_seen; |
43
|
5
|
|
|
|
|
15
|
for my $opt (@{ $service_provider->{required_init} }) { |
|
5
|
|
|
|
|
14
|
|
44
|
9
|
|
|
|
|
18
|
$is_seen{$opt}++; |
45
|
9
|
|
|
|
|
34
|
$for_service_provider->copy_option(\%opts, $opt); |
46
|
|
|
|
|
|
|
} |
47
|
5
|
|
|
|
|
9
|
for my $opt (@{ $service_provider->{optional_init} }) { |
|
5
|
|
|
|
|
11
|
|
48
|
12
|
100
|
|
|
|
47
|
if (not $is_seen{$opt}) { |
49
|
11
|
|
|
|
|
28
|
$is_seen{$opt}++; |
50
|
11
|
|
|
|
|
26
|
$for_service_provider->copy_option(\%opts, $opt, undef); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
5
|
|
|
|
|
9
|
$self->{for_service_provider} = $for_service_provider; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
20
|
$self->copy_option(\%opts, "early_refresh_time", 300); |
56
|
5
|
|
|
|
|
19
|
$self->copy_option(\%opts, "error_handler", undef); |
57
|
5
|
|
|
|
|
33
|
$self->copy_option(\%opts, "is_strict", 1); |
58
|
5
|
|
|
|
|
15
|
$self->copy_option(\%opts, "prerefresh", undef); |
59
|
5
|
|
|
|
|
14
|
$self->copy_option(\%opts, "save_tokens", undef); |
60
|
5
|
|
|
|
|
15
|
$self->copy_option(\%opts, "save_tokens_args", undef); |
61
|
5
|
|
|
|
|
19
|
$self->copy_option(\%opts, "token_string", undef); |
62
|
5
|
|
|
|
|
14
|
$self->copy_option(\%opts, "user_agent", undef); |
63
|
|
|
|
|
|
|
|
64
|
5
|
50
|
|
|
|
18
|
if ($self->{token_string}) { |
65
|
0
|
|
|
|
|
|
$self->load_token_string(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Standard shortcut request methods. |
70
|
|
|
|
|
|
|
sub delete { |
71
|
0
|
|
|
0
|
1
|
|
my ($self, @parameters) = @_; |
72
|
0
|
|
|
|
|
|
my @rest = $self->user_agent->_process_colonic_headers(\@parameters,1); |
73
|
0
|
|
|
|
|
|
my $request = HTTP::Request::Common::DELETE(@parameters); |
74
|
0
|
|
|
|
|
|
return $self->request($request, @rest); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get { |
78
|
0
|
|
|
0
|
1
|
|
my ($self, @parameters) = @_; |
79
|
0
|
|
|
|
|
|
my @rest = $self->user_agent->_process_colonic_headers(\@parameters,1); |
80
|
0
|
|
|
|
|
|
my $request = HTTP::Request::Common::GET(@parameters); |
81
|
0
|
|
|
|
|
|
return $self->request($request, @rest); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub head { |
85
|
0
|
|
|
0
|
1
|
|
my ($self, @parameters) = @_; |
86
|
0
|
|
|
|
|
|
my @rest = $self->user_agent->_process_colonic_headers(\@parameters,1); |
87
|
0
|
|
|
|
|
|
my $request = HTTP::Request::Common::HEAD(@parameters); |
88
|
0
|
|
|
|
|
|
return $self->request($request, @rest); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub post { |
92
|
0
|
|
|
0
|
1
|
|
my ($self, @parameters) = @_; |
93
|
0
|
0
|
|
|
|
|
my @rest = $self->user_agent->_process_colonic_headers(\@parameters, (ref($parameters[1]) ? 2 : 1)); |
94
|
0
|
|
|
|
|
|
my $request = HTTP::Request::Common::POST(@parameters); |
95
|
0
|
|
|
|
|
|
return $self->request($request, @rest); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub put { |
99
|
0
|
|
|
0
|
1
|
|
my ($self, @parameters) = @_; |
100
|
0
|
0
|
|
|
|
|
my @rest = $self->user_agent->_process_colonic_headers(\@parameters, (ref($parameters[1]) ? 2 : 1)); |
101
|
0
|
|
|
|
|
|
my $request = HTTP::Request::Common::PUT(@parameters); |
102
|
0
|
|
|
|
|
|
return $self->request($request, @rest); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub request { |
106
|
0
|
|
|
0
|
1
|
|
my ($self, $request, @rest) = @_; |
107
|
0
|
|
|
|
|
|
return $self->access_token->request($self, $request, @rest); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Now all of the methods that I need. |
111
|
|
|
|
|
|
|
sub token_string { |
112
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
113
|
0
|
0
|
|
|
|
|
if ($self->{access_token}) { |
114
|
0
|
|
|
|
|
|
my $ref = $self->{access_token}->to_ref; |
115
|
0
|
|
|
|
|
|
$ref->{_class} = ref($self->{access_token}); |
116
|
0
|
|
|
|
|
|
return encode_json($ref); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else { |
119
|
0
|
|
|
|
|
|
return undef; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# This does the actual saving. |
124
|
|
|
|
|
|
|
sub _set_tokens { |
125
|
0
|
|
|
0
|
|
|
my ($self, %opts) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $tokens = $self->extract_option(\%opts, "tokens"); |
128
|
0
|
|
|
|
|
|
my $skip_save = $self->extract_option(\%opts, "skip_save", 0); |
129
|
0
|
|
|
|
|
|
assert_options_empty(\%opts); |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
if (ref($tokens)) { |
132
|
|
|
|
|
|
|
# Assume we have tokens. |
133
|
0
|
|
|
|
|
|
$self->{access_token} = $tokens; |
134
|
0
|
0
|
0
|
|
|
|
if ($self->{save_tokens} and not $skip_save) { |
135
|
0
|
|
|
|
|
|
my $as_string = $self->token_string; |
136
|
0
|
|
|
|
|
|
$self->{save_tokens}->($as_string, @{$self->{save_tokens_args}}); |
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
|
return; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else { |
141
|
|
|
|
|
|
|
# Assume we have an error message. |
142
|
0
|
|
|
|
|
|
return $self->error($tokens); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub authorization_url { |
147
|
0
|
|
|
0
|
1
|
|
my ($self, %opts) = @_; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# If we get here, the service provider does it. |
150
|
0
|
|
|
|
|
|
my $url = $self->{service_provider}->authorization_url($self, %opts); |
151
|
0
|
0
|
|
|
|
|
if ($url =~ / /) { |
152
|
|
|
|
|
|
|
# Assume an error. |
153
|
0
|
|
|
|
|
|
return $self->error($url); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
else { |
156
|
0
|
|
|
|
|
|
return $url; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub api_url_base { |
161
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
162
|
0
|
|
0
|
|
|
|
return $self->{service_provider}->api_url_base || ''; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub make_api_call { |
166
|
0
|
|
|
0
|
1
|
|
my ($self, $uri, $params, $headers) = @_; |
167
|
0
|
0
|
|
|
|
|
my $url = $uri =~ m|^http| ? $uri : $self->api_url_base.$uri; |
168
|
0
|
0
|
|
|
|
|
if ($self->{service_provider}->can('default_api_headers')) { |
169
|
0
|
|
|
|
|
|
my $service_provider_headers = $self->{service_provider}->default_api_headers; |
170
|
0
|
0
|
0
|
|
|
|
$headers = ref $headers eq 'HASH' ? { %$headers, %$service_provider_headers } : $service_provider_headers || {}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
my $response = $params ? $self->post($url, Content => encode_json($params), %$headers) : $self->get($url, %$headers); |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
if (! $response->is_success()) { |
176
|
|
|
|
|
|
|
#$self->error('failed call to: '.$url.'; status_line='.$response->status_line.'; full error='.$response->error_as_HTML.'; content='.$response->content); |
177
|
0
|
|
0
|
|
|
|
$self->{'_api_call_error'} = $response->error_as_HTML || $response->status_line; |
178
|
0
|
|
|
|
|
|
return undef; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $content = $response->content; |
182
|
0
|
0
|
|
|
|
|
return 1 if ! $content; # success |
183
|
0
|
|
|
|
|
|
return eval { decode_json($content) }; # return decoded JSON if response has a body |
|
0
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
0
|
1
|
|
sub api_call_error { return shift->{'_api_call_error'}; } |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub request_tokens { |
189
|
0
|
|
|
0
|
1
|
|
my ($self, %opts) = @_; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# If we get here, the service provider does it. |
192
|
0
|
|
|
|
|
|
my $tokens = $self->{service_provider}->request_tokens($self, %opts); |
193
|
|
|
|
|
|
|
# _set_tokens will set an error if needed. |
194
|
0
|
|
|
|
|
|
return $self->_set_tokens(tokens => $tokens); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub can_refresh_tokens { |
198
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
199
|
0
|
0
|
|
|
|
|
if (not $self->{access_token}) { |
200
|
0
|
|
|
|
|
|
return 0; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else { |
203
|
0
|
|
|
|
|
|
my %opts = ($self->{access_token}->for_refresh(), @_); |
204
|
0
|
|
|
|
|
|
return $self->{service_provider}->can_refresh_tokens($self, %opts); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub refresh_access_token { |
209
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
210
|
0
|
0
|
|
|
|
|
if (not $self->{access_token}) { |
211
|
0
|
|
|
|
|
|
croak("Cannot try to refresh access token without tokens"); |
212
|
|
|
|
|
|
|
} |
213
|
0
|
|
|
|
|
|
my %opts = ($self->{access_token}->for_refresh(), @_); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# Give a chance for the hook to do it. |
216
|
0
|
0
|
|
|
|
|
if ($self->{prerefresh}) { |
217
|
0
|
|
|
|
|
|
my $tokens = $self->{prerefresh}->($self, %opts); |
218
|
0
|
0
|
|
|
|
|
if ($tokens) { |
219
|
0
|
0
|
|
|
|
|
if (not (ref($tokens))) { |
220
|
|
|
|
|
|
|
# Did I get JSON? |
221
|
0
|
|
|
|
|
|
my $data = eval {decode_json($tokens)}; |
|
0
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
0
|
0
|
0
|
|
|
|
if ($data and not $@) { |
224
|
0
|
0
|
|
|
|
|
my $class = $data->{_class} or croak("No _class in token_string '$tokens'"); |
225
|
0
|
|
|
|
|
|
eval {load($class)}; |
|
0
|
|
|
|
|
|
|
226
|
0
|
0
|
|
|
|
|
if ($@) { croak("Can't load access token class '$class': $@"); } |
|
0
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
$tokens = $class->from_ref($data); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
} |
230
|
0
|
|
|
|
|
|
return $self->_set_tokens(tokens => $tokens, skip_save => 1); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
my $tokens = $self->{service_provider}->refreshed_tokens($self, %opts); |
235
|
|
|
|
|
|
|
# _set_tokens will set an error if needed. |
236
|
0
|
|
|
|
|
|
return $self->_set_tokens(tokens => $tokens); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub access_token { |
240
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
return $self->{access_token}; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub should_refresh { |
246
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
247
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
return $self->access_token->should_refresh($self->{early_refresh_time}); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub expires_time { |
252
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
253
|
0
|
0
|
|
|
|
|
return 0 if ! $self->{access_token}; |
254
|
0
|
|
|
|
|
|
return $self->access_token->expires_time; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub set_early_refresh_time { |
258
|
0
|
|
|
0
|
1
|
|
my ($self, $early_refresh_time) = @_; |
259
|
0
|
|
|
|
|
|
$self->{early_refresh_time} = $early_refresh_time; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub set_is_strict { |
263
|
0
|
|
|
0
|
1
|
|
my ($self, $strict) = @_; |
264
|
0
|
|
|
|
|
|
$self->{is_strict} = $strict; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub is_strict { |
268
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
269
|
0
|
|
|
|
|
|
return $self->{is_strict}; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub set_error_handler { |
273
|
0
|
|
|
0
|
1
|
|
my ($self, $handler) = @_; |
274
|
0
|
|
|
|
|
|
$self->{error_handler} = @_; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub error { |
278
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
279
|
0
|
0
|
|
|
|
|
if ($self->{error_handler}) { |
280
|
0
|
|
|
|
|
|
return $self->{error_handler}->(@_); |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
else { |
283
|
0
|
|
|
|
|
|
croak(@_); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub for_service_provider { |
288
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
289
|
0
|
|
0
|
|
|
|
return $self->{for_service_provider} ||= {}; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
sub set_prerefresh { |
293
|
0
|
|
|
0
|
1
|
|
my ($self, $prerefresh) = @_; |
294
|
0
|
|
|
|
|
|
$self->{prerefresh} = $prerefresh; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub set_save_tokens { |
298
|
0
|
|
|
0
|
1
|
|
my ($self, $save_tokens) = @_; |
299
|
0
|
|
|
|
|
|
$self->{save_tokens} = $save_tokens; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub set_user_agent { |
303
|
0
|
|
|
0
|
1
|
|
my ($self, $agent) = @_; |
304
|
0
|
|
|
|
|
|
$self->{user_agent} = $agent; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
sub load_token_string { |
308
|
0
|
|
|
0
|
0
|
|
my ($self, $token_string) = @_; |
309
|
0
|
|
0
|
|
|
|
$token_string ||= $self->{token_string}; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
# Probably not the object that I need in access_token. |
312
|
0
|
|
|
|
|
|
my $tokens = eval{ decode_json($token_string) }; |
|
0
|
|
|
|
|
|
|
313
|
0
|
0
|
|
|
|
|
if ($@) { |
314
|
0
|
|
|
|
|
|
croak("While decoding token_string: $@"); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
my $class = $tokens->{_class} |
318
|
0
|
0
|
|
|
|
|
or croak("No _class in token_string '$token_string'"); |
319
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
eval {load($class)}; |
|
0
|
|
|
|
|
|
|
321
|
0
|
0
|
|
|
|
|
if ($@) { |
322
|
0
|
|
|
|
|
|
croak("Can't load access token class '$class': $@"); |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# I will assume this works. |
326
|
0
|
|
|
|
|
|
$self->{access_token} = $class->from_ref($tokens); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
sub user_agent { |
330
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
331
|
0
|
|
0
|
|
|
|
return $self->{user_agent} ||= LWP::UserAgent->new(); |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
1; # End of LWP::Authen::OAuth2 |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
__END__ |