com.google.api.ads.common.lib.auth
Class ClientLoginTokens

java.lang.Object
  extended by com.google.api.ads.common.lib.auth.ClientLoginTokens

public class ClientLoginTokens
extends Object

ClientLogin token provider.

Example usage:
String clientLoginToken = new ClientLoginTokens(ClientLoginTokens.ADWORDS_SERVICE).fromFile();

Author:
Adam Rogal

Field Summary
static String ADWORDS_SERVICE
          Service to use to request ClientLogin tokens for AdWords.
static String DFP_SERVICE
           
 
Constructor Summary
ClientLoginTokens(String service)
          Constructor.
 
Method Summary
 String from(org.apache.commons.configuration.Configuration config)
          Obtains a ClientLoginToken either stored in the specified configuration or using an email and password stored in the configuration to obtain a new one

Understands the following properties suffixes: clientLoginToken email password For example, the AdWords ClientLoginToken can be read from: api.adwords.clientLoginToken
 String from(String email, String password)
          Requests the user's authentication token.
 String from(String email, String password, String loginToken, String loginCaptcha)
          Requests the user's authentication token.
 String fromFile()
          Loads credentials from a properties file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath
 String fromFile(File path)
          Populates this builder from a properties file from a specified path.
 String fromFile(String path)
          Populates this builder from a properties file from a specified path.
 String fromFile(URL path)
          Populates this builder from a properties file from a specified path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADWORDS_SERVICE

public static final String ADWORDS_SERVICE
Service to use to request ClientLogin tokens for AdWords.

See Also:
Constant Field Values

DFP_SERVICE

public static final String DFP_SERVICE
See Also:
Constant Field Values
Constructor Detail

ClientLoginTokens

public ClientLoginTokens(String service)
Constructor.

Parameters:
service - the service name i.e. gam or adwords
Method Detail

fromFile

public String fromFile()
                throws ClientLoginException
Loads credentials from a properties file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath

Throws:
ClientLoginException

fromFile

public String fromFile(String path)
                throws ClientLoginException
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
ClientLoginException

fromFile

public String fromFile(File path)
                throws ClientLoginException
Populates this builder from a properties file from a specified path.

Parameters:
path - the path to load properties from
Returns:
Builder populated with properties.
Throws:
ClientLoginException

fromFile

public String fromFile(URL path)
                throws ClientLoginException
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
ClientLoginException

from

public String from(org.apache.commons.configuration.Configuration config)
            throws ClientLoginException
Obtains a ClientLoginToken either stored in the specified configuration or using an email and password stored in the configuration to obtain a new one

Understands the following properties suffixes: For example, the AdWords ClientLoginToken can be read from: api.adwords.clientLoginToken

Parameters:
config -
Returns:
ClientLoginToken on success or an exception.
Throws:
ClientLoginException

from

public String from(String email,
                   String password)
            throws ClientLoginException
Requests the user's authentication token.

Parameters:
email - the email to fetch the token for
password - the password to fetch the token for
Returns:
the user's new authentication token
Throws:
ClientLoginException - if the token could not be generated

from

public String from(String email,
                   String password,
                   String loginToken,
                   String loginCaptcha)
            throws ClientLoginException
Requests the user's authentication token.

Parameters:
email - the email to fetch the token for
password - the password to fetch the token for
loginToken - the login token. Can be null if not needed.
loginCaptcha - the login CAPTCHA. Can be null if not needed.
Returns:
the user's new authentication token
Throws:
ClientLoginException - if the token could not be generated


Copyright © 2012. All Rights Reserved.