| 1 | package LWP::Authen::OAuth2::AccessToken::Bearer; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Bearer access tokens for OAuth2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | our $VERSION = '0.20'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use base "LWP::Authen::OAuth2::AccessToken"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub _request { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_request: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 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 | ▶ | my $try_refresh = ($response->header("WWW-Authenticate")||'') =~ m/\binvalid_token\b/ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/10
($response->header("WWW-Authenticate") || "") =~ /\binvalid_token\b/ or ($response->header("Client-Warning") || "") =~ /Missing Authenticate header/ or $response->content =~ /\bExpiredAccessToken\b/
($response->header("WWW-Authenticate") || "") =~ /\binvalid_token\b/ or ($response->header("Client-Warning") || "") =~ /Missing Authenticate header/
$response->header('WWW-Authenticate') || ''
$response->header('Client-Warning') || ''
MC/DC0%0/3
($response->header("WWW-Authenticate") || "") =~ /\binvalid_token\b/ or ($response->header("Client-Warning") || "") =~ /Missing Authenticate header/ or $response->content =~ /\bExpiredAccessToken\b/
$response->header('WWW-Authenticate')
$response->header('Client-Warning')
$response->content =~ /\bExpiredAccessToken\b/
Truth table0%0/4
A or B or C
A= $response->header('WWW-Authenticate')B= $response->header('Client-Warning')C= $response->content =~ /\bExpiredAccessToken\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 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||