+# REST::Google::Apps::Provisioning also lacks a way to do this
+sub REST::Google::Apps::Provisioning::captcha_auth {
+ my $self = shift;
+
+ return( 1 ) if $self->{'token'};
+
+ my ( $arg );
+ %{$arg} = @_;
+
+ map { $arg->{lc($_)} = $arg->{$_} } keys %{$arg};
+
+ foreach my $param ( qw/ username password / ) {
+ $arg->{$param} || croak( "Missing required '$param' argument" );
+ }
+
+ my @postargs = (
+ 'accountType' => 'HOSTED',
+ 'service' => 'apps',
+ 'Email' => $arg->{'username'} . '@' . $self->{'domain'},
+ 'Passwd' => $arg->{'password'},
+ );
+ if ( $arg->{'logincaptcha'} ) {
+ push @postargs,
+ 'logintoken' => $arg->{'logintoken'},
+ 'logincaptcha'=> $arg->{'logincaptcha'}
+ ;
+ }
+ my $response = $self->{'lwp'}->post(
+ 'https://www.google.com/accounts/ClientLogin',
+ \@postargs
+ );
+
+ $response->is_success() || return( 0 );
+
+ foreach ( split( /\n/, $response->content() ) ) {
+ $self->{'token'} = $1 if /^Auth=(.+)$/;
+ last if $self->{'token'};
+ }
+
+ return( 1 ) if $self->{'token'} || return( 0 );
+}
+