Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit b330828

Browse files
authored
Fix example for latest OAuth library
2 parents 99b1a64 + 9d7dd65 commit b330828

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

v2/python/basic_list_apks_service_account.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from apiclient.discovery import build
2222
import httplib2
23-
from oauth2client import client
23+
from oauth2client.service_account import ServiceAccountCredentials
2424

2525

2626
SERVICE_ACCOUNT_EMAIL = (
@@ -33,20 +33,15 @@
3333

3434

3535
def main():
36-
# Load the key in PKCS 12 format that you downloaded from the Google APIs
37-
# Console when you created your Service account.
38-
f = file('key.p12', 'rb')
39-
key = f.read()
40-
f.close()
41-
4236
# Create an httplib2.Http object to handle our HTTP requests and authorize it
4337
# with the Credentials. Note that the first parameter, service_account_name,
4438
# is the Email address created for the Service account. It must be the email
4539
# address associated with the key that was created.
46-
credentials = client.SignedJwtAssertionCredentials(
40+
# The second parameter is the path to your PKCS 12 key
41+
credentials = ServiceAccountCredentials.from_p12_keyfile(
4742
SERVICE_ACCOUNT_EMAIL,
48-
key,
49-
scope='https://www.googleapis.com/auth/androidpublisher')
43+
'key.p12',
44+
scopes='https://www.googleapis.com/auth/androidpublisher')
5045
http = httplib2.Http()
5146
http = credentials.authorize(http)
5247

@@ -70,7 +65,7 @@ def main():
7065
print 'versionCode: %s, binary.sha1: %s' % (
7166
apk['versionCode'], apk['binary']['sha1'])
7267

73-
except client.AccessTokenRefreshError:
68+
except oauth2client.client.AccessTokenRefreshError:
7469
print ('The credentials have been revoked or expired, please re-run the '
7570
'application to re-authorize')
7671

0 commit comments

Comments
 (0)