« blib/lib/Google/Ads/AdWords/FaultDetail.pm
↑ Summary
blib/lib/Google/Ads/Common/OAuth2ApplicationsHandler.pm »
| 1 | # Copyright 2012, Google Inc. All Rights Reserved. | ||||||||||
| 2 | # | ||||||||||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| 4 | # you may not use this file except in compliance with the License. | ||||||||||
| 5 | # You may obtain a copy of the License at | ||||||||||
| 6 | # | ||||||||||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 8 | # | ||||||||||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||||||||||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| 12 | # See the License for the specific language governing permissions and | ||||||||||
| 13 | # limitations under the License. | ||||||||||
| 14 | |||||||||||
| 15 | package Google::Ads::AdWords::AuthTokenHandler; | ||||||||||
| 16 | |||||||||||
| 17 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 9 | ▶ | use version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 9 | ▶ | use base qw(Google::Ads::Common::AuthTokenHandler); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | # The following needs to be on one line because CPAN uses a particularly hacky | ||||||||||
| 22 | # eval() to determine module versions. | ||||||||||
| 23 | 9 | ▶ | use Google::Ads::AdWords::Constants; our $VERSION = ${Google::Ads::AdWords::Constants::VERSION}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | 9 | ▶ | use Class::Std::Fast; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | # Class methods from Google::Ads::Common::AuthTokenHandler | ||||||||||
| 28 | 0 | ▶ | sub prepare_request { | ||||||||
|
Subroutine
prepare_request: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 29 | 0 | my ($self, $endpoint, $http_headers, $envelope) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 0 | my $version = $self->get_api_client()->get_version(); | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | if ($version gt Google::Ads::AdWords::Constants::LAST_SUPPORTED_CLIENT_LOGIN_VERSION) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | my $message = "ClientLogin is not supported in " . $version . | |||||||||
| 35 | " of the AdWords API. Please refer to the ClientLogin to OAuth2" . | ||||||||||
| 36 | " migration guide at" . | ||||||||||
| 37 | " https://developers.google.com/adwords/api/docs/guides/clientlogin-to-oauth2-migration-guide" . | ||||||||||
| 38 | " for more information."; | ||||||||||
| 39 | 0 | ▶ | $self->get_api_client()->get_die_on_faults() ? | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | die($message) : | ||||||||||
| 41 | warn($message); | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | my $xmlns = "https://adwords.google.com/api/adwords/cm/" . $version; | |||||||||
| 45 | 0 | my $header = "<authToken xmlns=\"$xmlns\">" . $self->__get_auth_token() . | |||||||||
| 46 | "</authToken>"; | ||||||||||
| 47 | |||||||||||
| 48 | 0 | $envelope =~ s/(<RequestHeader [^>]+>)/$1${header}/; | |||||||||
| 49 | |||||||||||
| 50 | 0 | return HTTP::Request->new('POST', $endpoint, $http_headers, $envelope); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub _service { | ||||||||
|
Subroutine
_service: not called CC=1 SCAR=6.9
| |||||||||||
| 54 | 0 | return "adwords"; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 9 | 1; | |||||||||
| 58 | |||||||||||
| 59 | =pod | ||||||||||
| 60 | |||||||||||
| 61 | =head1 NAME | ||||||||||
| 62 | |||||||||||
| 63 | Google::Ads::AdWords::AuthTokenHandler | ||||||||||
| 64 | |||||||||||
| 65 | =head1 DESCRIPTION | ||||||||||
| 66 | |||||||||||
| 67 | A concrete implementation of L<Google::Ads::Common::AuthTokenHandler> that | ||||||||||
| 68 | defines the auth service name required to access AdWords API servers using | ||||||||||
| 69 | ClientLogin, see | ||||||||||
| 70 | L<https://developers.google.com/accounts/docs/AuthForInstalledApps> for details | ||||||||||
| 71 | of the protocol. | ||||||||||
| 72 | |||||||||||
| 73 | Refer to the base object L<Google::Ads::Common::AuthTokenHandler> | ||||||||||
| 74 | for a complete documentation of all the methods supported by this handler class. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 METHODS | ||||||||||
| 77 | |||||||||||
| 78 | =head2 _service | ||||||||||
| 79 | |||||||||||
| 80 | Method defined by L<Google::Ads::AdWords::AuthTokenHandler> and implemented | ||||||||||
| 81 | in this class as a requirement for the ClientLogin protocol. | ||||||||||
| 82 | |||||||||||
| 83 | =head3 Returns | ||||||||||
| 84 | |||||||||||
| 85 | Returns the AdWords API service name used to generate the AuthToken. | ||||||||||
| 86 | |||||||||||
| 87 | =head2 prepare_request | ||||||||||
| 88 | |||||||||||
| 89 | Method defined by B<Google::Ads::AdWords::AuthTokenHandler> and implemented | ||||||||||
| 90 | in this class as a requirement for sending requests to the AdWords API. | ||||||||||
| 91 | |||||||||||
| 92 | =head3 Returns | ||||||||||
| 93 | |||||||||||
| 94 | A new L<HTTP:Request> with the I<authToken> header properly set with the | ||||||||||
| 95 | authorization information. | ||||||||||
| 96 | |||||||||||
| 97 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 98 | |||||||||||
| 99 | Copyright 2012 Google Inc. | ||||||||||
| 100 | |||||||||||
| 101 | Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| 102 | you may not use this file except in compliance with the License. | ||||||||||
| 103 | You may obtain a copy of the License at | ||||||||||
| 104 | |||||||||||
| 105 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 106 | |||||||||||
| 107 | Unless required by applicable law or agreed to in writing, software | ||||||||||
| 108 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 109 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| 110 | See the License for the specific language governing permissions and | ||||||||||
| 111 | limitations under the License. | ||||||||||
| 112 | |||||||||||
| 113 | =head1 AUTHOR | ||||||||||
| 114 | |||||||||||
| 115 | David Torres E<lt>david.t at google.comE<gt> | ||||||||||
| 116 | |||||||||||
| 117 | =head1 REPOSITORY INFORMATION | ||||||||||
| 118 | |||||||||||
| 119 | $Rev: $ | ||||||||||
| 120 | $LastChangedBy: $ | ||||||||||
| 121 | $Id: $ | ||||||||||
| 122 | |||||||||||
| 123 | =cut | ||||||||||