File Coverage

blib/lib/CatalystX/OAuth2/Request/RefreshToken.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 4 50.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 15 17 88.2


line stmt bran cond sub pod time code
1             package CatalystX::OAuth2::Request::RefreshToken;
2 8     8   53 use Moose;
  8         19  
  8         60  
3 8     8   52757 use URI;
  8         24  
  8         1586  
4             with 'CatalystX::OAuth2';
5              
6             # ABSTRACT: The oauth2 refresh token
7              
8             has grant_type => ( is => 'ro', required => 1 );
9             has refresh_token => ( is => 'ro' );
10              
11             around _params => sub { shift->(@_), qw(grant_type refresh_token) };
12              
13             sub _build_query_parameters {
14 1     1   3 my ($self) = @_;
15              
16 1 50       28 my $code = $self->store->find_code_from_refresh( $self->refresh_token )
17             or return {
18             error => 'invalid_grant',
19             error_description => 'The provided authorization grant '
20             . 'is invalid, expired, revoked, does not match the '
21             . 'redirection URI used in the authorization request, '
22             . 'or was issued to another client.'
23             };
24              
25 1 50       4081 my $token =
26             $self->store->create_access_token_from_refresh( $self->refresh_token )
27             or return { error => 'internal_error' };
28             return {
29 1         82 access_token => $token->as_string,
30             token_type => $token->type,
31             expires_in => $token->expires_in
32             };
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =head1 NAME
42              
43             CatalystX::OAuth2::Request::RefreshToken - The oauth2 refresh token
44              
45             =head1 VERSION
46              
47             version 0.001006
48              
49             =head1 AUTHOR
50              
51             Eden Cardim <edencardim@gmail.com>
52              
53             =head1 COPYRIGHT AND LICENSE
54              
55             This software is copyright (c) 2017 by Suretec Systems Ltd.
56              
57             This is free software; you can redistribute it and/or modify it under
58             the same terms as the Perl 5 programming language system itself.
59              
60             =cut