Problem: I\'ve been using Python Script Samples by Google to upload the apk to Play Store and to get list of apps published via my account (list_apks.py and
I had the same problem and also I did not have pyOpenSSL installed which is required when using from_p12_keyfile()
.
from_p12_keyfile()
Raises:
NotImplementedError if pyOpenSSL is not installed / not the active crypto library.
I read the JSON file into dictionary and passed it to from_json_keyfile_dict()
like this:
import json
from oauth2client.service_account import ServiceAccountCredentials
# other imports and code from sample...
# modified authentication part
data = {}
with open('api.json') as json_file:
data = json.load(json_file)
credentials = ServiceAccountCredentials.from_json_keyfile_dict(
data,
scopes=['https://www.googleapis.com/auth/androidpublisher']
)
http = httplib2.Http()
http = credentials.authorize(http)
# do what ever you want with the returned object
api.json file refers to the file which gets created when service account is created.
Of course there is also couple other functions to get the credentials but this solution helped me to get the stuff working. Maybe this will help someone in future.
Reference: Oauth2Client.service_account