Skip to content

Commit bc3423e

Browse files
committed
AdWords v201607 Sunset.
1 parent 46d3123 commit bc3423e

File tree

563 files changed

+2074
-10329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

563 files changed

+2074
-10329
lines changed

ChangeLog

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
5.6.0 -- 06/01/17:
1+
6.0.0 -- 6/27/17:
2+
* Removed support for AdWords v201607.
3+
* Improved logging support. Can now specify logging configuration from the
4+
configuration file.
5+
* Added new GoogleAccessTokenClient, a non-refreshable client that only requires
6+
the access token.
7+
* Resolved issues:
8+
- Issue 84: https://github.com/googleads/googleads-python-lib/issues/84
9+
- Issue 171: https://github.com/googleads/googleads-python-lib/issues/171
10+
11+
5.6.0 -- 6/01/17:
212
* Added support for AdWords v201705.
313

4-
5.5.0 -- 05/23/17:
14+
5.5.0 -- 5/23/17:
515
* Added more expressive python utility to build DFP PQL statements.
616
* Support building DFP SOAP entities with native python date/datetime objects.
717
* Added support and examples for DFP v201705.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ for API change announcements and other news.
101101

102102

103103
## How do I log SOAP interactions?
104-
The library uses Python's built in logging framework. If you wish to log your
105-
SOAP interactions to stdout, you can do the following:
104+
The library uses Python's built in logging framework. You can specify your
105+
configuration via the configuration file; see [googleads.yaml](https://github.com/googleads/googleads-python-lib/blob/master/googleads.yaml)
106+
for an example.
107+
108+
Alternatively, you can manually specify your logging configuration. For example,
109+
if you want to log your SOAP interactions to stdout, you can do the following:
106110
```python
107111
logging.basicConfig(level=logging.INFO, format=googleads.util.LOGGER_FORMAT)
108112
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
@@ -121,6 +125,10 @@ logging.getLogger('googleads.common').removeFilter(
121125
googleads.util.GetGoogleAdsCommonFilter())
122126
logging.getLogger('suds.client').removeFilter(
123127
googleads.util.GetSudsClientFilter())
128+
logging.getLogger('suds.mx.core').removeFilter(
129+
googleads.util.GetSudsMXCoreFilter())
130+
logging.getLogger('suds.mx.literal').removeFilter(
131+
googleads.util.GetSudsMXLiteralFilter())
124132
logging.getLogger('suds.transport').removeFilter(
125133
googleads.util.GetSudsTransportFilter())
126134
```
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
1.0.1 - 1/5/2015
2-
- Updated dependencies listed in README, for the changes introduced in googleads
3-
3.0.0.
1+
1.0.2 -- 6/21/16:
2+
- Fixed issue #171:
3+
https://github.com/googleads/googleads-python-lib/issues/171
4+
5+
1.0.1 -- 1/5/15:
6+
- Updated dependencies listed in README, for the changes introduced in
7+
googleads 3.0.0.
48

59
1.0.0:
6-
- Initial release of the demo.
10+
- Initial release of the demo.

examples/adwords/adwords_appengine_demo/README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ prepared your OAuth2 Credentials via the Google Developers Console.
3636
1. Install Python v2.7, which you can get
3737
[here](https://www.python.org/downloads).
3838

39-
2. Install [pip](http://pip.readthedocs.org/en/latest/installing.html),
39+
1. Install [pip](http://pip.readthedocs.org/en/latest/installing.html),
4040
if you have not done so already.
4141

42-
3. If you don't have one already,
42+
1. If you don't have one already,
4343
[sign up for a Google Account](https://www.google.com/accounts/NewAccount).
4444
This account will be used to access your AdWords credentials used in making
4545
API requests.
4646

47-
4. Download the latest version of the
47+
1. Download the latest version of the
4848
[App Engine SDK](https://developers.google.com/appengine/downloads) and
4949
unpack its content. This demo should be compatible with v1.9.11+.
5050

51-
5. Install googleads with the following command:
51+
1. Install googleads with the following command:
5252

5353
`$ pip install googleads`
5454

@@ -57,36 +57,42 @@ prepared your OAuth2 Credentials via the Google Developers Console.
5757
should also have installed the dependencies referred to in the following
5858
steps.
5959

60-
6. Copy the httplib2 package from your Python installation's dist-packages
60+
1. Copy the httplib2 package from your Python installation's dist-packages
6161
directory into this project.
6262

63-
7. Copy the oauth2client package from your Python installation's dist-packages
63+
1. Copy the oauth2client package from your Python installation's dist-packages
6464
directory into this project.
6565

66-
8. Copy the pytz package from your Python installation's dist-packages
66+
1. Copy the pyasn1 package from your Python installation's dist-packages
6767
directory into this project.
6868

69-
9. Copy socks.py from the PySocks tarball found in your Python installation's
69+
1. Copy socks.py from the PySocks tarball found in your Python installation's
7070
dist-packages directory into this project.
7171

72-
10. Copy the suds package from your Python installation's dist-packages
72+
1. Copy the rsa package from your Python installation's dist-packages
73+
into this project.
74+
75+
1. Copy the suds package from your Python installation's dist-packages
76+
into this project.
77+
78+
1. Copy xmltodict.py from your Python installation's dist-packages directory
7379
directory into this project.
7480

75-
11. Create an App Engine application in the
81+
1. Create an App Engine application in the
7682
[Google App Engine Console](https://appengine.google.com/).
7783

78-
12. Go to this project's app.yaml, and enter in your application name for the
84+
1. Go to this project's app.yaml, and enter in your application name for the
7985
"application" field.
8086

81-
13. You can now deploy this project by running the following command:
87+
1. You can now deploy this project by running the following command:
8288

8389
`python $APPENGINE_SDK_DIR/appcfg --oauth2 update .`
8490

85-
14. When you go to your App for the first time, you will need to log in and
91+
1. When you go to your App for the first time, you will need to log in and
8692
provide OAuth2 and AdWords API credentials. You can use credentials
8793
generated via the generate_refresh_token.py example.
8894

89-
15. With all information entered, you can now use the UI to view and modify
95+
1. With all information entered, you can now use the UI to view and modify
9096
your account details.
9197

9298

examples/adwords/adwords_appengine_demo/app.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ handlers:
1313
script: demo.main.app
1414
login: required
1515
secure: always
16+
17+
libraries:
18+
- name: ssl
19+
version: latest

examples/adwords/adwords_appengine_demo/handlers/api_handler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
import time
2020

2121

22-
from suds.cache import NoCache
23-
2422
from demo import VERSION
2523
from googleads.adwords import AdWordsClient
2624
from googleads.errors import GoogleAdsError
2725
from googleads.oauth2 import GoogleRefreshTokenClient
26+
from suds.cache import NoCache
2827

2928

3029
class APIHandler(object):
@@ -48,7 +47,7 @@ def __init__(self, client_id, client_secret, refresh_token,
4847
refresh_token)
4948
self.client = AdWordsClient(dev_token, credentials, self._USER_AGENT,
5049
client_customer_id=manager_account_id,
51-
cache=NoCache)
50+
cache=NoCache())
5251

5352
def AddAdGroup(self, client_customer_id, campaign_id, name, status):
5453
"""Create a new ad group.

examples/adwords/adwords_appengine_demo/handlers/ndb_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ def InitUser():
4343

4444

4545
def UpdateUserCredentials(client_id, client_secret, refresh_token,
46-
manager_account_id, developer_token):
46+
adwords_manager_cid, developer_token):
4747
"""Update the credentials associated with application user.
4848
4949
Args:
5050
client_id: str Client Id retrieved from the developer's console.
5151
client_secret: str Client Secret retrieved from the developer's console.
5252
refresh_token: str Refresh token generated with the above client id/secret.
53-
manager_account_id: str Customer Id for the AdWords manager account.
53+
adwords_manager_cid: str Customer Id for the AdWords manager account.
5454
developer_token: str Developer Token for the AdWords account.
5555
"""
5656
app_user = AppUser.query(AppUser.user == users.get_current_user()).fetch()[0]
5757

5858
app_user.client_id = client_id
5959
app_user.client_secret = client_secret
6060
app_user.refresh_token = refresh_token
61-
app_user.manager_account_id = manager_account_id
61+
app_user.adwords_manager_cid = adwords_manager_cid
6262
app_user.developer_token = developer_token
6363

6464
app_user.put()

examples/adwords/adwords_appengine_demo/templates/show_credentials.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</tr>
2525
<tr>
2626
<th><label for="adwords_manager_cid">AdWords Manager Account Id: </label></th>
27-
<td><input type="text" name="manager_account_id" size="35"
28-
value="{{ manager_account_id }}"/></td>
27+
<td><input type="text" name="adwords_manager_cid" size="35"
28+
value="{{ adwords_manager_cid }}"/></td>
2929
</tr>
3030
<tr>
3131
<th><label for="dev_token">Developer Token: </label></th>
@@ -39,4 +39,4 @@
3939
</tr>
4040
</table>
4141
</form>
42-
{% endblock %}
42+
{% endblock %}

examples/adwords/adwords_appengine_demo/views/update_credentials_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def post(self):
4141
UpdateUserCredentials(self.request.get('client_id'),
4242
self.request.get('client_secret'),
4343
self.request.get('refresh_token'),
44-
self.request.get('manager_account_id'),
44+
self.request.get('adwords_manager_cid'),
4545
self.request.get('dev_token'))
4646
self.redirect('/showCredentials')
4747
except Exception, e:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2017 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""Initializes an AdWordsClient using GoogleAccessTokenClient.
18+
19+
Note that unlike clients initialized with GoogleRefreshTokenClient, those
20+
initialized with GoogleAccessTokenClient can't refresh.
21+
"""
22+
23+
import argparse
24+
import datetime
25+
from googleads import adwords
26+
from googleads import oauth2
27+
import httplib2
28+
from oauth2client import client
29+
30+
31+
GOOGLE_OAUTH2_ENDPOINT = 'https://accounts.google.com/o/oauth2/token'
32+
33+
# OAuth2 credential information.
34+
DEFAULT_CLIENT_ID = 'INSERT_CLIENT_ID_HERE'
35+
DEFAULT_CLIENT_SECRET = 'INSERT_CLIENT_SECRET_HERE'
36+
DEFAULT_REFRESH_TOKEN = 'INSERT_REFRESH_TOKEN_HERE'
37+
38+
# AdWords API information.
39+
DEFAULT_CLIENT_CUSTOMER_ID = 'INSERT_CLIENT_CUSTOMER_ID_HERE'
40+
DEFAULT_DEVELOPER_TOKEN = 'INSERT_DEVELOPER_TOKEN_HERE'
41+
USER_AGENT = 'INSERT_USER_AGENT_HERE'
42+
43+
44+
parser = argparse.ArgumentParser(
45+
description=('Creates an AdWordsClient using a GoogleAccessToken with an '
46+
'access token generated with the given credentials.'))
47+
parser.add_argument('--client_id', default=DEFAULT_CLIENT_ID,
48+
help='Client Id retrieved from the Developer\'s Console.')
49+
parser.add_argument('--client_secret', default=DEFAULT_CLIENT_SECRET,
50+
help='Client Secret retrieved from the Developer\'s '
51+
'Console.')
52+
parser.add_argument('--refresh_token', default=DEFAULT_REFRESH_TOKEN,
53+
help='The refresh token used to generate an access token.')
54+
parser.add_argument('--client_customer_id', default=DEFAULT_CLIENT_CUSTOMER_ID,
55+
help='The client customer ID for your AdWords account.')
56+
parser.add_argument('--developer_token', default=DEFAULT_DEVELOPER_TOKEN,
57+
help='The refresh token used to generate an access token.')
58+
59+
60+
def main(access_token, token_expiry, client_customer_id, developer_token,
61+
user_agent):
62+
oauth2_client = oauth2.GoogleAccessTokenClient(access_token, token_expiry)
63+
64+
adwords_client = adwords.AdWordsClient(
65+
developer_token, oauth2_client, user_agent,
66+
client_customer_id=client_customer_id)
67+
68+
customer = adwords_client.GetService('CustomerService').getCustomers()[0]
69+
print 'You are logged in as customer: %s' % customer['customerId']
70+
71+
72+
if __name__ == '__main__':
73+
args = parser.parse_args()
74+
75+
# Retrieve a new access token for use in this example. In a production
76+
# application, you may use a credential store to share access tokens for a
77+
# given user across applications.
78+
oauth2credentials = client.OAuth2Credentials(
79+
None, args.client_id, args.client_secret, args.refresh_token,
80+
datetime.datetime(1980, 1, 1, 12), GOOGLE_OAUTH2_ENDPOINT,
81+
USER_AGENT)
82+
83+
oauth2credentials.refresh(httplib2.Http())
84+
85+
main(oauth2credentials.access_token, oauth2credentials.token_expiry,
86+
args.client_customer_id, args.developer_token, USER_AGENT)

0 commit comments

Comments
 (0)