blib/lib/LWP/Authen/OAuth2/AccessToken/Bearer.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 10 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 SCAR 17.9
CC
2
Cov
0%
_request
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.0
1 package LWP::Authen::OAuth2::AccessToken::Bearer;
2  
3 # ABSTRACT: Bearer access tokens for OAuth2
4 our $VERSION = '0.19'; # VERSION
5  
6 use strict;
7 use warnings;
8 use base "LWP::Authen::OAuth2::AccessToken";
9 use Storable qw(dclone);
10  
11 sub _request {
12 my ($self, $oauth2, $request, @rest) = @_;
13 my $actual_request = dclone($request);
14 # This is where we sign it.
15 $actual_request->header('Authorization' => "Bearer $self->{access_token}");
16 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 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 return ($response, $try_refresh);
25 }
26  
27  
28 1;
29  
30 __END__