API/Account/ProgrammaticLogin.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 31 CC 3 SCAR 19.5
CC
3
Cov
0%
authenticate
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package WWW::Google::API::Account::ProgrammaticLogin;
2  
3 use strict;
4 use warnings;
5  
6 use base qw(WWW::Google::API::Account);
7  
8 sub authenticate {
9 my $self = shift;
10 my $conn = shift;
11  
12 my $auth_token = undef;
13 my $client_login_uri = 'https://www.google.com/accounts/clientlogin';
14  
15 $self->ua->default_header( 'content-type' => 'application/x-www-form-urlencoded' );
16  
17 my $response = $self->ua->post( $client_login_uri,
18 { accountType => 'hosted_or_google',
19 Email => $conn->{api_user},
20 Passwd => $conn->{api_pass},
21 service => $conn->{service},
22 }
23 );
24
25 if ( $response->is_success ) {
26 my $content = $response->content;
27 my @content = split("\n", $content);
28 for ( @content ) {
29 $auth_token = $1 if /^Auth=(.*)$/;
30 }
31 } else {
32 die $response->status_line;
33 }
34  
35 return $auth_token;
36 }
37  
38 1;