Properties

$configurationLoader

$configurationLoader :

Type

$jsonKeyFilePath

$jsonKeyFilePath :

Type

$scopes

$scopes :

Type

$impersonatedEmail

$impersonatedEmail :

Type

$clientId

$clientId :

Type

$clientSecret

$clientSecret :

Type

$refreshToken

$refreshToken :

Type

Methods

__construct()

__construct()

fromFile()

fromFile(string  $path = null): \Google\AdsApi\Common\OAuth2TokenBuilder

Reads configuration settings from the specified filepath. The filepath is optional, and if omitted, it will look for the default configuration filename in the home directory of the user running PHP.

Parameters

string $path

the filepath

Throws

\InvalidArgumentException

if the configuration file could not be found

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder populated from the configuration

withJsonKeyFilePath()

withJsonKeyFilePath(string|null  $jsonKeyFilePath): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes an absolute path to an OAuth2 JSON key file when using service account flow. Required and only applicable when using service account flow.

Parameters

string|null $jsonKeyFilePath

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

withScopes()

withScopes(string|null  $scopes): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes OAuth2 scopes. Required and only applicable when using service account flow.

Parameters

string|null $scopes

a space-delimited list of scopes

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

withImpersonatedEmail()

withImpersonatedEmail(string|null  $impersonatedEmail): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes an email of account to impersonate when using service account flow. Optional and only applicable when using service account flow.

Parameters

string|null $impersonatedEmail

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

withClientId()

withClientId(string|null  $clientId): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes an OAuth2 client ID. Required when using installed application or web application flow.

Parameters

string|null $clientId

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

withClientSecret()

withClientSecret(string|null  $clientSecret): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes an OAuth2 client secret. Required when using installed application or web application flow.

Parameters

string|null $clientSecret

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

withRefreshToken()

withRefreshToken(string|null  $refreshToken): \Google\AdsApi\Common\OAuth2TokenBuilder

Includes an OAuth2 refresh token. Required when using installed application or web application flow.

Parameters

string|null $refreshToken

Returns

\Google\AdsApi\Common\OAuth2TokenBuilder

this builder

build()

build(): mixed

Creates a new instance of the data object being populated. This method should call defaultOptionals() and validate().

Returns

mixed —

the data object

defaultOptionals()

defaultOptionals()

Sets all optional fields to their default if they are `null`.

validate()

validate()

Checks that required fields have been included and all included fields are valid (e.g., URIs are valid).

getJsonKeyFilePath()

getJsonKeyFilePath(): string|null

Gets the JSON key file path.

Returns

string|null

getScopes()

getScopes(): string|null

Gets the scopes.

Returns

string|null

getImpersonatedEmail()

getImpersonatedEmail(): string|null

Gets the impersonated email.

Returns

string|null

getClientId()

getClientId(): string|null

Gets the client ID.

Returns

string|null

getClientSecret()

getClientSecret(): string|null

Gets the client secret.

Returns

string|null

getRefreshToken()

getRefreshToken(): string|null

Gets the refresh token.

Returns

string|null