line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Launchpad; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
749
|
$Net::Launchpad::AUTHORITY = 'cpan:ADAMJS'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
$Net::Launchpad::VERSION = '1.0.4'; |
6
|
|
|
|
|
|
|
# ABSTRACT: Launchpad.net Authentication |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
624
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
9917
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
1623
|
use Mojo::UserAgent; |
|
1
|
|
|
|
|
246628
|
|
|
1
|
|
|
|
|
9
|
|
10
|
1
|
|
|
1
|
|
33
|
use Mojo::JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
11
|
1
|
|
|
1
|
|
4
|
use Mojo::URL; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
15
|
use Mojo::Parameters; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
use Function::Parameters { |
14
|
1
|
|
|
|
|
69
|
func => 'function_strict', |
15
|
|
|
|
|
|
|
method => 'method_strict' |
16
|
1
|
|
|
1
|
|
544
|
}; |
|
1
|
|
|
|
|
1945
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'staging' => 0; |
19
|
|
|
|
|
|
|
has 'consumer_key'; |
20
|
|
|
|
|
|
|
has 'callback_uri'; |
21
|
|
|
|
|
|
|
has 'json' => method { Mojo::JSON->new }; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'ua' => method { |
24
|
|
|
|
|
|
|
my $ua = Mojo::UserAgent->new; |
25
|
|
|
|
|
|
|
$ua->transactor->name("Net::Salesforce"); |
26
|
|
|
|
|
|
|
return $ua; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'nonce' => method { |
30
|
|
|
|
|
|
|
my @a = ('A' .. 'Z', 'a' .. 'z', 0 .. 9); |
31
|
|
|
|
|
|
|
my $nonce = ''; |
32
|
|
|
|
|
|
|
for (0 .. 31) { |
33
|
|
|
|
|
|
|
$nonce .= $a[rand(scalar(@a))]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
return $nonce; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'params' => method { |
39
|
|
|
|
|
|
|
return { |
40
|
|
|
|
|
|
|
oauth_callback => $self->callback_uri, |
41
|
|
|
|
|
|
|
oauth_consumer_key => $self->consumer_key, |
42
|
|
|
|
|
|
|
oauth_version => '1.0a', |
43
|
|
|
|
|
|
|
oauth_signature_method => 'PLAINTEXT', |
44
|
|
|
|
|
|
|
oauth_signature => '&', |
45
|
|
|
|
|
|
|
oauth_token => undef, |
46
|
|
|
|
|
|
|
oauth_token_secret => undef, |
47
|
|
|
|
|
|
|
oauth_timestamp => time, |
48
|
|
|
|
|
|
|
oauth_nonce => $self->nonce |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
0
|
1
|
|
method api_host { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
return Mojo::URL->new('https://launchpad.net/') unless $self->staging; |
54
|
0
|
|
|
|
|
|
return Mojo::URL->new('https://staging.launchpad.net'); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
0
|
1
|
|
method request_token_path { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $self->api_host->path('+request-token'); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
0
|
1
|
|
method access_token_path { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self->api_host->path('+access-token'); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
0
|
1
|
|
method authorize_token_path { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return $self->api_host->path('+authorize-token'); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
0
|
1
|
|
method request_token { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $tx = |
71
|
|
|
|
|
|
|
$self->ua->post( |
72
|
|
|
|
|
|
|
$self->request_token_path->to_string => form => $self->params); |
73
|
0
|
0
|
|
|
|
|
die $tx->res->body unless $tx->success; |
74
|
0
|
|
|
|
|
|
my $params = Mojo::Parameters->new($tx->res->body); |
75
|
0
|
|
|
|
|
|
my $token = $params->param('oauth_token'); |
76
|
0
|
|
|
|
|
|
my $secret = $params->param('oauth_token_secret'); |
77
|
0
|
|
|
|
|
|
return ($token, $secret); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
0
|
0
|
|
method authorize_token($token, $token_secret) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$self->params->{oauth_token} = $token; |
82
|
0
|
|
|
|
|
|
$self->params->{oauth_token_secret} = $token_secret; |
83
|
0
|
|
|
|
|
|
my $url = $self->authorize_token_path->query($self->params); |
84
|
0
|
|
|
|
|
|
return $url->to_string; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
0
|
1
|
|
method access_token($token, $secret) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->params->{oauth_token} = $token; |
89
|
0
|
|
|
|
|
|
$self->params->{oauth_token_secret} = $secret; |
90
|
0
|
|
|
|
|
|
$self->params->{oauth_signature} = |
91
|
|
|
|
|
|
|
'&' . $secret; |
92
|
0
|
|
|
|
|
|
my $tx = |
93
|
|
|
|
|
|
|
$self->ua->post( |
94
|
|
|
|
|
|
|
$self->access_token_path->to_string => form => $self->params); |
95
|
0
|
0
|
|
|
|
|
die $tx->res->body unless $tx->success; |
96
|
0
|
|
|
|
|
|
my $params = Mojo::Parameters->new($tx->res->body); |
97
|
0
|
|
|
|
|
|
return ($params->param('oauth_token'), $params->param('oauth_token_secret')); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |