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

Migrate SignedJwtAssertionCredentials to ServiceAccountCredentials #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions v3/python/basic_list_apks_service_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from apiclient.discovery import build
import httplib2
from oauth2client import client
from oauth2client.service_account import ServiceAccountCredentials
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to actually use it. You are still using SignedJwtAssertionCredentials.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, oauth2client is deprecated now, so I would probably completely replace this sample with one using the Credentials from google.oauth2 instead.

NOTE: I am not part of the Google community, just sharing my opinion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to actually use it. You are still using SignedJwtAssertionCredentials.

You're right! I overlooked that.

Also, oauth2client is deprecated now, so I would probably completely replace this sample with one using the Credentials from google.oauth2 instead.

NOTE: I am not part of the Google community, just sharing my opinion

Yeah, I'll leave it open to Google and on how they decide to proceed with the samples. Good to have your comment here though for others to read.



SERVICE_ACCOUNT_EMAIL = (
Expand All @@ -35,9 +36,7 @@
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()
key = 'key.p12'

# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
Expand All @@ -46,7 +45,7 @@ def main():
credentials = client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/androidpublisher')
scopes=['https://www.googleapis.com/auth/androidpublisher'])
http = httplib2.Http()
http = credentials.authorize(http)

Expand Down