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

Commit

Permalink
Fix example for latest OAuth library
Browse files Browse the repository at this point in the history
nlativy authored Feb 25, 2019
2 parents 99b1a64 + 9d7dd65 commit b330828
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions v2/python/basic_list_apks_service_account.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@

from apiclient.discovery import build
import httplib2
from oauth2client import client
from oauth2client.service_account import ServiceAccountCredentials


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


def main():
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
f = file('key.p12', 'rb')
key = f.read()
f.close()

# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
# is the Email address created for the Service account. It must be the email
# address associated with the key that was created.
credentials = client.SignedJwtAssertionCredentials(
# The second parameter is the path to your PKCS 12 key
credentials = ServiceAccountCredentials.from_p12_keyfile(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/androidpublisher')
'key.p12',
scopes='https://www.googleapis.com/auth/androidpublisher')
http = httplib2.Http()
http = credentials.authorize(http)

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

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

0 comments on commit b330828

Please sign in to comment.