Google::Ads::Common::AuthToken


Back to Top


NAME

Google::Ads::Common::AuthToken

Back to Top


SYNOPSIS

 use Google::Ads::Common::AuthToken;
 my $token;
 eval {
   $token = Google::Ads::Common::AuthToken::get_token({
     email => "user@domain.com",
     password => "password",
     service => "adwords"
   });
 };
 if ($@) {
   # $@ will contain a string explaining why the token request failed.
 } else {
   # Make use of $token.
 }

Back to Top


DESCRIPTION

Google::Ads::Common::AuthToken exposes one static method, get_token().

Back to Top


METHODS

get_token

A static method that attempts to log in to Google's ClientLogin service with the provided credentials. The credentials should correspond to an active Google Account; more info on Google Accounts can be found at https://www.google.com/accounts/ManageAccount.

Parameters

A hash reference with two keys: { # The service name to access. service => "adwords", # The email address of a Google Account. email => "user@domain.com", # The password for the Google Account. password => "password", }

Returns

A string containing the auth token suitable for use with the API.

Exceptions

If the attempt to log in fails, either due to bad or missing credentials or an HTTP error contacting the service, get_token() will die() with a descriptive error message.

Back to Top


LICENSE AND COPYRIGHT

Copyright 2011 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Back to Top


AUTHOR

Jeffrey Posnick <api.jeffy at gmail.com>

David Torres <api.davidtorres at gmail.com>

Back to Top


REPOSITORY INFORMATION

 $Rev: $
 $LastChangedBy: $
 $Id: $

Back to Top

 Google::Ads::Common::AuthToken