CatalystX/OAuth2/Request/AuthToken.pm

filter: Statementstmt 100% 20 / 20 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.4% 27 / 28 SCAR 11.0
CC
3
Cov
96%
_build_query_parameters
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« CatalystX/OAuth2/Request/RefreshToken.pm ↑ Summary CatalystX/OAuth2/Client.pm »
1 package CatalystX::OAuth2::Request::AuthToken;
2 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 10 with 'CatalystX::OAuth2';
6  
7 # ABSTRACT: An oauth2 authentication token implementation
8  
9 10 has grant_type => ( is => 'ro', required => 1 );
10 10 has code => ( is => 'ro', required => 1 );
11 10 has refresh_token => (
12 isa => 'Bool',
13 is => 'rw',
14 default => 0
15 );
16  
17 5 ▶around _params => sub { shift->(@_), qw(code grant_type) };
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 sub _build_query_parameters {
20 3 ▶ my ($self) = @_;
Subroutine _build_query_parameters: called CC=3 SCAR=11.0
21  
22 3 ▶ my $code = $self->store->find_client_code( $self->code )
Branch: 1 branch
BranchTrueFalseTotal
my $code = $self->store->find_client_code($self->code) or return {"error", "invalid_grant", "error_description", "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."} 0 3 3
23 or return {
24 error => 'invalid_grant',
25 error_description => 'The provided authorization grant '
26 . 'is invalid, expired, revoked, does not match the '
27 . 'redirection URI used in the authorization request, '
28 . 'or was issued to another client.'
29 };
30  
31 3 my $with_refresh = $self->refresh_token;
32 3 my $token = $self->store->create_access_token( $self->code, $with_refresh );
33 3 my $res = {
34 access_token => $token->as_string,
35 token_type => $token->type,
36 expires_in => $token->expires_in,
37 };
38 3 ▶ $res->{refresh_token} = $token->to_refresh_token->as_string
Branch: 1 branch
BranchTrueFalseTotal
if $with_refresh 1 2 3
39 if $with_refresh;
40  
41 3 return $res;
42 }
43  
44 10 1;
45  
46 __END__
47  
48 =pod
49  
50 =head1 NAME
51  
52 CatalystX::OAuth2::Request::AuthToken - An oauth2 authentication token implementation
53  
54 =head1 VERSION
55  
56 version 0.001006
57  
58 =head1 AUTHOR
59  
60 Eden Cardim <edencardim@gmail.com>
61  
62 =head1 COPYRIGHT AND LICENSE
63  
64 This software is copyright (c) 2017 by Suretec Systems Ltd.
65  
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as the Perl 5 programming language system itself.
68  
69 =cut
« CatalystX/OAuth2/Request/RefreshToken.pm ↑ Summary CatalystX/OAuth2/Client.pm »