| 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
| |||||||||||
| 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
| |||||||||||
| 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 | ||||||||||