File Coverage

blib/lib/Google/Ads/Common/OAuthApplicationsHandlerInterface.pm
Criterion Covered Total %
statement 9 13 69.2
branch n/a
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 20 70.0


line stmt bran cond sub pod time code
1             # Copyright 2013, 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::Common::OAuthApplicationsHandlerInterface;
16              
17 2     2   3033 use strict;
  2         6  
  2         71  
18 2     2   13 use warnings;
  2         6  
  2         77  
19 2     2   19 use base qw(Google::Ads::Common::AuthHandlerInterface);
  2         7  
  2         417  
20              
21             # Method to retrieve an authorization URL for the user to put in a
22             # browser and authorize a request token.
23             # Meant to be implemented by a concrete class, which should issue a request
24             # token and return a valid URL for the user to authorize the token.
25             # The implementor must save the request token in the token attribute for later
26             # use by the upgrade_token method.
27             # A callback URL can be passed to re-direct the user after the token is
28             # authorized.
29             sub get_authorization_url {
30 0     0 1   my ($self, $callback) = @_;
31 0           die "Needs to be implemented by subclass";
32             }
33              
34             # Method to issue an access token given an authorization code. After calling
35             # this method the auth handler should be prepared to prepare HTTP requests
36             # against protected resources.
37             sub issue_access_token {
38 0     0 1   my ($self, $auth_code) = @_;
39 0           die "Needs to be implemented by subclass";
40             }
41              
42             1;
43              
44             =pod
45              
46             =head1 NAME
47              
48             Google::Ads::Common::OAuthApplicationsHandlerInterface
49              
50             =head1 DESCRIPTION
51              
52             Abstract interface for oauth flows that require user interaction.
53              
54             Meant be implemented by concrete OAuth handlers that require user intervention
55             for authorizing requests against the API.
56              
57             =head1 METHODS
58              
59             =head2 get_authorization_url
60              
61             Meant to be implemented by a concrete class, which should return a valid URL
62             for the user to authorize the access to the API.
63              
64             =head3 Returns
65              
66             The URL for the user to authorize access to his account. The user first must
67             login in the account that want to grant access to.
68              
69             =head2 issue_access_token
70              
71             Method to upgrade/obtain an authorized access token.
72              
73             =head3 Parameters
74              
75             =over
76              
77             =item *
78              
79             The verifier code returned to your callback page or printed out if using 'oob'
80             special callback URL.
81              
82             =back
83              
84             =head1 LICENSE AND COPYRIGHT
85              
86             Copyright 2013 Google Inc.
87              
88             Licensed under the Apache License, Version 2.0 (the "License");
89             you may not use this file except in compliance with the License.
90             You may obtain a copy of the License at
91              
92             http://www.apache.org/licenses/LICENSE-2.0
93              
94             Unless required by applicable law or agreed to in writing, software
95             distributed under the License is distributed on an "AS IS" BASIS,
96             WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
97             See the License for the specific language governing permissions and
98             limitations under the License.
99              
100             =head1 REPOSITORY INFORMATION
101              
102             $Rev: $
103             $LastChangedBy: $
104             $Id: $
105              
106             =cut