The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Google::Ads::GoogleAds::OAuth2ServiceAccountsHandler

DESCRIPTION

A concrete implementation of Google::Ads::GoogleAds::Common::OAuth2BaseHandler that supports OAuth2 for service accounts and defines the scope required to access the Google Ads API server.

See https://developers.google.com/identity/protocols/oauth2/service-account for details of the protocol.

ATTRIBUTES

Each of these attributes can be set via Google::Ads::GoogleAds::OAuth2ServiceAccountsHandler->new().

Alternatively, there is a get_ and set_ method associated with each attribute for retrieving or setting them dynamically.

api_client

A reference to the API client used to handle the API requests.

json_key_file_path

The absolute path to the local JSON key file for the OAuth2 service account.

impersonated_email

The email address account to impersonate, when the service account has been delegated domain wide access.

access_token

Stores an OAuth2 access token after the authorization flow is followed or for you to manually set it in case you had it previously stored. If this is manually set this handler will verify its validity before preparing a request.

additional_scopes

Stores additional OAuth2 scopes as a comma-separated string. These scopes define which services the tokens are allowed to access, e.g. https://www.googleapis.com/auth/analytics.

METHODS

initialize

Initializes the handler with the API client object and the properties such as json_key_file_path and impersonated_email, used for generating authorization requests.

Parameters

  • A required api_client with a reference to the API client object handling the requests against the API.

  • A hash reference with the following keys:

      {
        jsonKeyFilePath   => "json-key-file-path",
        impersonatedEmail => "impersonated-email",
        accessToken       => "access-token",
        additionalScopes  => "additional-scopes",
      }

    Refer to the documentation of the properties as "json_key_file_path", "impersonated_email", "access_token" and "additional_scopes".

prepare_request

Refer to Google::Ads::GoogleAds::Common::AuthHandlerInterface documentation of this method.

is_auth_enabled

Refer to Google::Ads::GoogleAds::Common::AuthHandlerInterface documentation of this method.

_scope

Method defined by Google::Ads::GoogleAds::Common::OAuth2BaseHandler and implemented in this class to return the required OAuth2 scopes as an array.

_refresh_access_token

Method defined by Google::Ads::GoogleAds::Common::OAuth2BaseHandler and implemented in this class to refresh the stored OAuth2 access token.

__formatted_scopes

Private method to return the OAuth2 scopes as a list of strings separated by commas. This is the format expected when sending the OAuth request.

Returns

The string of OAuth2 scopes separated by commas.

LICENSE AND COPYRIGHT

Copyright 2021 Google LLC

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.

REPOSITORY INFORMATION

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