| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Google::AuthSub::Response; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
782
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
481
|
|
|
4
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Net::Google::AuthSub::Response - a response from a Net::Google::AuthSub request |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $response = $auth->login($user, $pass); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
if ($response->is_success) { |
|
15
|
|
|
|
|
|
|
print "Yay!\n"; |
|
16
|
|
|
|
|
|
|
} else { |
|
17
|
|
|
|
|
|
|
if ($response->error eq 'CaptchaRequired') { |
|
18
|
|
|
|
|
|
|
print "Captcha Image ".$response->captchaurl; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new C C |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Create a new response. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
0
|
|
|
0
|
1
|
|
my ($class, $response, $url, %opts) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my %values; |
|
37
|
0
|
0
|
|
|
|
|
if ($opts{_compat}->{json_response}) { |
|
38
|
0
|
|
|
|
|
|
eval 'use JSON::Any'; |
|
39
|
0
|
0
|
|
|
|
|
die "You need to install JSON::Any to use JSON responses" if $@; |
|
40
|
0
|
|
|
|
|
|
%values = %{JSON::Any->from_json($response->content)}; |
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} else { |
|
42
|
0
|
|
|
|
|
|
foreach my $line (split /\n/, $response->content) { |
|
43
|
0
|
|
|
|
|
|
chomp($line); |
|
44
|
0
|
|
|
|
|
|
my ($key, $value) = split '=', $line; |
|
45
|
0
|
|
|
|
|
|
$values{lc($key)} = $value; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return bless { _response => $response, _values => \%values, _url => $url }, $class; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 is_success |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns whether the response was a sucess or not. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub is_success { |
|
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
62
|
0
|
|
|
|
|
|
return $self->{_response}->is_success; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SUCCESS METHODS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Methods available if the response was a success. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 auth |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The authorisation token if the response is a success. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 sid |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Not used yet. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 lsid |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Not used yet. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 ERROR METHODS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Methods available if the response was an error. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 error |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The error code. Can be one of |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item BadAuthentication |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The login request used a username or password that is not recognized. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item NotVerified |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The account email address has not been verified. The user will need to |
|
99
|
|
|
|
|
|
|
access their Google account directly to resolve the issue before logging |
|
100
|
|
|
|
|
|
|
in using a non-Google application. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item TermsNotAgreed |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The user has not agreed to terms. The user will need to access their |
|
105
|
|
|
|
|
|
|
Google account directly to resolve the issue before logging in using a |
|
106
|
|
|
|
|
|
|
non-Google application. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item CaptchaRequired |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
A CAPTCHA is required. (A response with this error code will also |
|
111
|
|
|
|
|
|
|
contain an image URL and a CAPTCHA token.) |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item Unknown |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The error is unknown or unspecified; the request contained invalid input |
|
116
|
|
|
|
|
|
|
or was malformed. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item AccountDeleted |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The user account has been deleted. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item AccountDisabled |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The user account has been disabled. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item ServiceDisabled |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The user's access to the specified service has been disabled. (The user |
|
129
|
|
|
|
|
|
|
account may still be valid.) |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item ServiceUnavailable |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The service is not available; try again later. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 url |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The url of a page describing the error. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 captchatoken |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The token required to authenticate a captcha. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 captchaurl |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The full url of the captcha image. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub captchaurl { |
|
152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
153
|
0
|
|
|
|
|
|
my $url = $self->{_values}->{captchaurl}; |
|
154
|
0
|
|
|
|
|
|
return $self->{url}."/accounts/$url"; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
158
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
my $type = ref($self) |
|
161
|
|
|
|
|
|
|
or die "$self is not an object"; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my $name = $AUTOLOAD; |
|
164
|
0
|
|
|
|
|
|
$name =~ s/.*://; # strip fully-qualified portion |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
0
|
|
|
|
|
if (@_) { |
|
167
|
0
|
|
|
|
|
|
return $self->{_values}->{$name} = shift; |
|
168
|
|
|
|
|
|
|
} else { |
|
169
|
0
|
|
|
|
|
|
return $self->{_values}->{$name}; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
0
|
|
|
sub DESTROY {} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |