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