line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::OAuth::Handler::RequestTokenV1; |
2
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
11
|
use parent qw(Plack::Middleware::OAuth::Handler); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
5
|
2
|
|
|
2
|
|
2144
|
use Net::OAuth; |
|
2
|
|
|
|
|
1534
|
|
|
2
|
|
|
|
|
61
|
|
6
|
2
|
|
|
2
|
|
12
|
use Digest::MD5 qw(md5_hex); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
7
|
2
|
|
|
2
|
|
5195
|
use HTTP::Request::Common; |
|
2
|
|
|
|
|
8882
|
|
|
2
|
|
|
|
|
194
|
|
8
|
2
|
|
|
2
|
|
2225
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
56200
|
|
|
2
|
|
|
|
|
110
|
|
9
|
2
|
|
|
2
|
|
27
|
use DateTime; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
658
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub build_args { |
12
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
13
|
0
|
|
|
|
|
|
my $config = $self->config; |
14
|
|
|
|
|
|
|
return ( |
15
|
0
|
|
0
|
|
|
|
$self->build_v1_common_args, |
16
|
|
|
|
|
|
|
request_url => $config->{request_token_url}, |
17
|
|
|
|
|
|
|
request_method => $config->{request_token_method}, |
18
|
|
|
|
|
|
|
callback => $config->{callback} || $self->default_callback, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub run { |
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my $config = $self->config; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A; |
27
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# save it , becase we have to built callback URI from ENV.PATH_FINO and ENV.SCRIPT_NAME |
30
|
0
|
|
|
|
|
|
my $request = Net::OAuth->request("request token")->new( $self->build_args ); |
31
|
0
|
|
|
|
|
|
$request->sign; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $res = $ua->request(POST $request->to_url); # Post message to the Service Provider |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
36
|
0
|
|
|
|
|
|
my $response = Net::OAuth->response('request token')->from_post_body($res->content); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# got response token |
39
|
0
|
|
|
|
|
|
my $uri = URI->new( $config->{authorize_url} ); |
40
|
0
|
|
|
|
|
|
$uri->query_form( oauth_token => $response->token ); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->redirect( $uri ); |
43
|
|
|
|
|
|
|
# print "Got Request Token ", $response->token, "\n"; |
44
|
|
|
|
|
|
|
# print "Got Request Token Secret ", $response->token_secret, "\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
$self->on_error->( $self ) if $self->on_error; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# failed. |
50
|
0
|
|
|
|
|
|
return $self->render( $res->content ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |