public class ClientLoginTokens extends Object
ClientLoginTokens clientLoginTokens = new ClientLoginTokens.Builder()
.forApi(ClientLoginTokens.Api.ADWORDS)
.fromFile()
.build();
String clientLoginToken = clientLoginTokens.requestToken();
If you receive a CAPTCHA challenge you can supply the login token and captcha
in the requestToken function like:
String clientLoginToken;
try {
clientLoginToken = clientLoginTokens.requestToken();
} catch(ClientLoginException e) {
if (e.getCaptchaInfo != null) {
String loginCaptcha =
// redirect user to e.getCaptchaInfo.getCaptchaUrl() to get CAPTCHA;
String loginToken = captchaInformation.getCaptchaToken();
clientLoginToken =
clientLoginTokens.requestToken(loginCaptcha, loginToken);
}
}| Modifier and Type | Class and Description |
|---|---|
static class |
ClientLoginTokens.Api
Enum representing the API that ClientLoginTokens can be used for.
|
static class |
ClientLoginTokens.Builder
Pre-builder for ClientLoginTokens.
|
static class |
ClientLoginTokens.ForApiBuilder
Builder for ClientLoginTokens.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ADWORDS_SERVICE
Deprecated.
Use
ClientLoginTokens.Api.ADWORDS in Builder#forApi(Api). |
static String |
DFP_SERVICE
Deprecated.
Use
ClientLoginTokens.Api.DFP in Builder#forApi(Api). |
| Constructor and Description |
|---|
ClientLoginTokens(String service)
Deprecated.
Use
new ClientLoginTokens.Builder() instead |
| Modifier and Type | Method and Description |
|---|---|
String |
from(org.apache.commons.configuration.Configuration config)
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.from(config) instead. |
String |
from(String email,
String password)
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.withEmailAndPassword(email, password) instead. |
String |
from(String email,
String password,
String loginToken,
String loginCaptcha)
Deprecated.
Use
new ClientTokens.Builder()
.forApi(Api.ADWORDS)
.withEmailAndPassword(email, password)
.withLoginTokenAndCaptcha(loginToken,
loginCaptcha) instead. |
String |
fromFile()
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile() instead. |
String |
fromFile(File path)
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead. |
String |
fromFile(String path)
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead. |
String |
fromFile(URL path)
Deprecated.
Use
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead. |
String |
requestToken()
Requests a token with the email and password.
|
String |
requestToken(String captchaToken,
String captchaAnswer)
Requests a token with the email and password, along with information used
to validate a CAPTCHA'ed account.
|
@Deprecated public static final String ADWORDS_SERVICE
@Deprecated public static final String DFP_SERVICE
@Deprecated public ClientLoginTokens(String service)
new ClientLoginTokens.Builder() insteadservice - the service name i.e. gam or adwords@Deprecated public String fromFile() throws ClientLoginException, com.google.api.ads.common.lib.conf.ConfigurationLoadException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile() instead.com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be
loaded.ClientLoginException@Deprecated public String fromFile(String path) throws ClientLoginException, com.google.api.ads.common.lib.conf.ConfigurationLoadException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead.path - the path to try first as a resource, then as a filecom.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be
loaded.ClientLoginException@Deprecated public String fromFile(File path) throws ClientLoginException, com.google.api.ads.common.lib.conf.ConfigurationLoadException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead.path - the path to load properties fromcom.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be
loaded.ClientLoginException@Deprecated public String fromFile(URL path) throws ClientLoginException, com.google.api.ads.common.lib.conf.ConfigurationLoadException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.fromFile(path) instead.path - the path to try first as a resource, then as a filecom.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be
loaded.ClientLoginException@Deprecated public String from(org.apache.commons.configuration.Configuration config) throws ClientLoginException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.from(config) instead.api.adwords.clientLoginTokenconfig - ClientLoginException@Deprecated public String from(String email, String password) throws ClientLoginException
new ClientTokens.Builder().forApi(Api.ADWORDS)
.withEmailAndPassword(email, password) instead.email - the email to fetch the token forpassword - the password to fetch the token forClientLoginException - if the token could not be generated@Deprecated public String from(String email, String password, String loginToken, String loginCaptcha) throws ClientLoginException
new ClientTokens.Builder()
.forApi(Api.ADWORDS)
.withEmailAndPassword(email, password)
.withLoginTokenAndCaptcha(loginToken,
loginCaptcha) instead.email - the email to fetch the token forpassword - the password to fetch the token forloginToken - the login token. Can be null if not needed.loginCaptcha - the login CAPTCHA. Can be null if not needed.ClientLoginException - if the token could not be generatedpublic String requestToken(String captchaToken, String captchaAnswer) throws com.google.api.client.googleapis.auth.clientlogin.ClientLoginResponseException, IOException
captchaToken - the CAPTCHA token. i.e.
.ClientLogin.ErrorInfo#captchaToken ErrorInfo#captchaTokencaptchaAnswer - the CAPTCHA answer. i.e. fetched from
.ClientLogin.ErrorInfo#captchaUrl ErrorInfo#captchaUrlcom.google.api.client.googleapis.auth.clientlogin.ClientLoginResponseException - if the token could not be retrievedIOException - if there was a problem making the requestpublic String requestToken() throws com.google.api.client.googleapis.auth.clientlogin.ClientLoginResponseException, IOException
com.google.api.client.googleapis.auth.clientlogin.ClientLoginResponseException - if the token could not be retrieved, possibly
due to a CAPTCHA
challengeIOException - if there was a problem making the requestCopyright © 2012. All Rights Reserved.