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

NAME

Google::Ads::GoogleAds::Common::OAuth2BaseHandler

DESCRIPTION

An abstract base implementation that defines part of the logic required to use OAuth2 against Google APIs.

It is meant to be specialized and its "_scope", "_refresh_access_token" methods should be properly implemented.

ATTRIBUTES

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

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

  my %api_client_of : ATTR(:name<api_client> :default<>);
  my %client_id_of : ATTR(:name<client_id> :default<>);
  my %access_token_of : ATTR(:init_arg<access_token> :default<>);
  my %access_token_expires_of : ATTR(:name<access_token_expires> :default<>);

api_client

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

client_id

OAuth2 client id obtained from the Google APIs Console.

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.

METHODS

initialize

Initializes the handler with the API client object and the properties such as client_id and access_token.

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.

      {
        clientId    => "client-id",
        accessToken => "access-token"
      }

    Refer to the documentation of the "client_id" and "access_token" properties.

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

Meant to be implemented by a concrete class, which should return the required API scopes in an array for the OAuth2 protocol.

_refresh_access_token

Method called to refresh the stored OAuth2 access token. Implementors will issue an access token refresh request to the OAuth2 server.

LICENSE AND COPYRIGHT

Copyright 2019 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: $