line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2019, Google LLC |
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
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use strict; |
17
|
11
|
|
|
11
|
|
73
|
use warnings; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
246
|
|
18
|
11
|
|
|
11
|
|
42
|
|
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
1388
|
|
19
|
|
|
|
|
|
|
# Initializes the handler with the API client object and a given set of |
20
|
|
|
|
|
|
|
# properties. |
21
|
|
|
|
|
|
|
my ($self, $api_client, $properties) = @_; |
22
|
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
23
|
0
|
|
|
0
|
1
|
|
} |
24
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Method that prepares an HTTP::Request with the relevant authorization |
26
|
|
|
|
|
|
|
# data (i.e. headers, protected resource url, etc). |
27
|
|
|
|
|
|
|
my ($self, $http_method, $request_url, $http_headers, $request_content) = @_; |
28
|
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
0
|
1
|
|
|
31
|
0
|
|
|
|
|
|
# Returns true if the handler can prepare request with the appropriate |
32
|
|
|
|
|
|
|
# authorization info. |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
1; |
38
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Google::Ads::GoogleAds::Common::AuthHandlerInterface |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Interface to be implemented by concrete authorization handlers. Defines the |
48
|
|
|
|
|
|
|
necessary subroutines to build authorized requests against a Google API. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 initialize |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Initializes the handler with the API client object and a given set of properties, |
55
|
|
|
|
|
|
|
such as: client_id, client_secret, etc. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 Parameters |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
A required I<api_client> with a reference to the API client object handling the |
64
|
|
|
|
|
|
|
requests against the API. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
A required I<properties> with a reference to a hash of properties. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 prepare_request |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Constructs a L<HTTP::Request> object to send an authorized request to the API. |
75
|
|
|
|
|
|
|
Implementors will attach authorization headers to the request at this phase. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head3 Parameters |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
I<http_method>: HTTP request method, e.g. GET, POST. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
I<request_url>: URL to the resource to access. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
I<http_headers>: an array of HTTP headers to be included in the request. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
I<request_content>: a string as the payload to be sent in the request. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 is_auth_enabled |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Method called to check if the authorization has already been set up, so the |
102
|
|
|
|
|
|
|
L</prepare_request> method can be called. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head3 Returns |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
True, if the authorization is in place and the handler can prepare requests. |
107
|
|
|
|
|
|
|
False, otherwise. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright 2019 Google LLC |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
114
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
115
|
|
|
|
|
|
|
You may obtain a copy of the License at |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
120
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
121
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
122
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
123
|
|
|
|
|
|
|
limitations under the License. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 REPOSITORY INFORMATION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$Rev: $ |
128
|
|
|
|
|
|
|
$LastChangedBy: $ |
129
|
|
|
|
|
|
|
$Id: $ |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |