public static class OfflineCredentials.ForApiBuilder extends Object implements Builder<OfflineCredentials>
DEFAULT_CONFIGURATION_FILENAME
Modifier and Type | Method and Description |
---|---|
OfflineCredentials |
build()
Constructs this object.
|
OfflineCredentials.ForApiBuilder |
from(org.apache.commons.configuration.Configuration config)
Reads properties from the provided
Configuration object
Understands the following properties suffixes: refreshToken clientId clientSecret jsonKeyFilePath For example, the AdWords OAuth2 refresh token can be read from: api.adwords.refreshToken |
OfflineCredentials.ForApiBuilder |
fromFile()
Loads credentials from the "ads.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
|
OfflineCredentials.ForApiBuilder |
fromFile(File path)
Populates this builder from a properties file from a specified path.
|
OfflineCredentials.ForApiBuilder |
fromFile(String path)
Populates this builder from a properties file from a specified path.
|
OfflineCredentials.ForApiBuilder |
fromFile(URL path)
Populates this builder from a properties file from a specified path.
|
OfflineCredentials.ForApiBuilder |
withClientSecrets(String clientId,
String clientSecret)
Sets the client ID & secret to create the OAuth2 Credential with.
|
OfflineCredentials.ForApiBuilder |
withHttpTransport(com.google.api.client.http.HttpTransport httpTransport)
Sets the
HttpTransport to be used to make the request. |
OfflineCredentials.ForApiBuilder |
withJsonKeyFilePath(String jsonKeyFilePath)
Sets the path to a JSON key file for authenticating with a service account.
|
OfflineCredentials.ForApiBuilder |
withRefreshToken(String refreshToken)
Sets the refresh token to create the OAuth2 Credential with.
|
OfflineCredentials.ForApiBuilder |
withScopes(List<String> scopes)
Optionally sets scopes for authenticating with a service account.
|
OfflineCredentials.ForApiBuilder |
withServiceAccountUser(String serviceAccountUser)
Sets the service account user to impersonate.
|
OfflineCredentials.ForApiBuilder |
withTokenUrlServer(String tokenServerUrl)
Sets the token server URL.
|
public OfflineCredentials.ForApiBuilder fromFile(String path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<OfflineCredentials>
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.public OfflineCredentials.ForApiBuilder fromFile(File path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<OfflineCredentials>
path
- the path to load properties fromcom.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public OfflineCredentials.ForApiBuilder fromFile(URL path) throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<OfflineCredentials>
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.public OfflineCredentials.ForApiBuilder fromFile() throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Builder
fromFile
in interface Builder<OfflineCredentials>
com.google.api.ads.common.lib.conf.ConfigurationLoadException
- if the configuration could not be
loaded.public OfflineCredentials.ForApiBuilder from(org.apache.commons.configuration.Configuration config)
Configuration
object
api.adwords.refreshToken
from
in interface Builder<OfflineCredentials>
config
- the configurationpublic OfflineCredentials.ForApiBuilder withClientSecrets(String clientId, String clientSecret)
public OfflineCredentials.ForApiBuilder withRefreshToken(String refreshToken)
public OfflineCredentials.ForApiBuilder withJsonKeyFilePath(String jsonKeyFilePath)
public OfflineCredentials.ForApiBuilder withServiceAccountUser(String serviceAccountUser)
See https://developers.google.com/adwords/api/docs/guides/authentication#granting_impersonation_abilities for details.
serviceAccountUser
- the email address of the account to impersonate.public OfflineCredentials.ForApiBuilder withScopes(List<String> scopes)
OfflineCredentials.Api
. If you are using a refresh token,
the scope is set at the time the refresh token is generated, and this function is
a no-op.public OfflineCredentials.ForApiBuilder withHttpTransport(com.google.api.client.http.HttpTransport httpTransport)
HttpTransport
to be used to make the request. By
default, NetHttpTransport
will be used, but due to some
environment restrictions, you may want to use a different transport,
such as UrlFetchTransport
for AppEngine.public OfflineCredentials.ForApiBuilder withTokenUrlServer(String tokenServerUrl)
public OfflineCredentials build() throws ValidationException
Builder
build
in interface Builder<OfflineCredentials>
ValidationException
- if the provided data is not valid.Copyright © 2018. All Rights Reserved.