line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OAuth::Lite2::Server::GrantHandler::RefreshToken; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1233
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use parent 'OAuth::Lite2::Server::GrantHandler'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
97
|
use OAuth::Lite2::Server::Error; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
8
|
2
|
|
|
2
|
|
9
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
506
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub handle_request { |
11
|
4
|
|
|
4
|
1
|
138
|
my ($self, $dh) = @_; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
13
|
my $req = $dh->request; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
10
|
my $client_id = $req->param("client_id"); |
16
|
4
|
|
|
|
|
435
|
my $client_secret = $req->param("client_secret"); |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
28
|
my $refresh_token = $req->param("refresh_token") |
19
|
|
|
|
|
|
|
or OAuth::Lite2::Server::Error::InvalidRequest->throw( |
20
|
|
|
|
|
|
|
description => "'refresh_token' not found" |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
3
|
100
|
|
|
|
23
|
my $auth_info = $dh->get_auth_info_by_refresh_token($refresh_token) |
24
|
|
|
|
|
|
|
or OAuth::Lite2::Server::Error::InvalidGrant->throw; |
25
|
2
|
50
|
33
|
|
|
43
|
Carp::croak "OAuth::Lite2::Server::DataHandler::get_auth_info_by_refresh_token doesn't return OAuth::Lite2::Model::AuthInfo" |
26
|
|
|
|
|
|
|
unless ($auth_info |
27
|
|
|
|
|
|
|
&& $auth_info->isa("OAuth::Lite2::Model::AuthInfo")); |
28
|
|
|
|
|
|
|
|
29
|
2
|
100
|
|
|
|
6
|
OAuth::Lite2::Server::Error::InvalidClient->throw |
30
|
|
|
|
|
|
|
unless $auth_info->client_id eq $client_id; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
7
|
my $access_token = $dh->create_or_update_access_token( |
33
|
|
|
|
|
|
|
auth_info => $auth_info, |
34
|
|
|
|
|
|
|
); |
35
|
1
|
50
|
33
|
|
|
17
|
Carp::croak "OAuth::Lite2::Server::DataHandler::create_or_update_access_token doesn't return OAuth::Lite2::Model::AccessToken" |
36
|
|
|
|
|
|
|
unless ($access_token |
37
|
|
|
|
|
|
|
&& $access_token->isa("OAuth::Lite2::Model::AccessToken")); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
4
|
my $res = { |
40
|
|
|
|
|
|
|
token_type => 'Bearer', |
41
|
|
|
|
|
|
|
access_token => $access_token->token, |
42
|
|
|
|
|
|
|
}; |
43
|
1
|
50
|
|
|
|
7
|
$res->{expires_in} = $access_token->expires_in |
44
|
|
|
|
|
|
|
if $access_token->expires_in; |
45
|
1
|
50
|
|
|
|
8
|
$res->{refresh_token} = $auth_info->refresh_token |
46
|
|
|
|
|
|
|
if $auth_info->refresh_token; |
47
|
1
|
50
|
|
|
|
8
|
$res->{scope} = $auth_info->scope |
48
|
|
|
|
|
|
|
if $auth_info->scope; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
9
|
return $res; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
OAuth::Lite2::Server::GrantHandler::RefreshToken - handler for 'refresh-token' grant_type request |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $handler = OAuth::Lite2::Server::GrantHandler::RefreshToken->new; |
60
|
|
|
|
|
|
|
my $res = $handler->handle_request( $data_handler ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
handler for 'refresh-token' grant_type request. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 handle_request( $req ) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
See L document. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright (C) 2010 by Lyo Kato |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
81
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
82
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |