line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LWP::Authen::OAuth2::AccessToken::Bearer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Bearer access tokens for OAuth2 |
4
|
|
|
|
|
|
|
our $VERSION = '0.20'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
74218
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
69
|
|
7
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
8
|
2
|
|
|
2
|
|
12
|
use base "LWP::Authen::OAuth2::AccessToken"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1046
|
|
9
|
2
|
|
|
2
|
|
1339
|
use Storable qw(dclone); |
|
2
|
|
|
|
|
6728
|
|
|
2
|
|
|
|
|
494
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _request { |
12
|
0
|
|
|
0
|
|
|
my ($self, $oauth2, $request, @rest) = @_; |
13
|
0
|
|
|
|
|
|
my $actual_request = dclone($request); |
14
|
|
|
|
|
|
|
# This is where we sign it. |
15
|
0
|
|
|
|
|
|
$actual_request->header('Authorization' => "Bearer $self->{access_token}"); |
16
|
0
|
|
|
|
|
|
my $response = $oauth2->user_agent->request($actual_request, @rest); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# One would hope for a 401 status, but the specification only requires |
19
|
|
|
|
|
|
|
# this header. (Though recommends a 401 status.) |
20
|
0
|
0
|
0
|
|
|
|
my $try_refresh = ($response->header("WWW-Authenticate")||'') =~ m/\binvalid_token\b/ |
21
|
|
|
|
|
|
|
|| ($response->header('Client-Warning')||'') =~ m/Missing Authenticate header/ # Dwolla does not send WWW-Authenticate |
22
|
|
|
|
|
|
|
|| $response->content() =~ m/\bExpiredAccessToken\b/ |
23
|
|
|
|
|
|
|
? 1 : 0; |
24
|
0
|
|
|
|
|
|
return ($response, $try_refresh); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |