I have a service account and private key generated for the account with the app.
testxyz.json - contains the private key and service account information.
Here's the script:
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient.discovery import build
import ssl
import json
ssl._create_default_https_context = ssl._create_unverified_context
credentials = ServiceAccountCredentials.from_json_keyfile_name('testxyz.json',scopes=['https://www.googleapis.com/auth/androidpublisher'])
http = httplib2.Http()
http = credentials.authorize(http)
service = build('androidpublisher', 'v3', http=http)
print(service)
package_name = "xtestx"
reviews_resource = service.reviews()
print(reviews_resource)
reviews_page = reviews_resource.list(packageName=package_name,maxResults=100).execute()
reviews_list = reviews_page["reviews"]
infinite_loop_canary = 100
while "tokenPagination" in reviews_page:
reviews_page = reviews_resource.list(packageName=package_name,maxResults=100).execute()
token=reviews_page["tokenPagination"]["nextPageToken"],
maxResults=100).execute()
reviews_list.extend(reviews_page["reviews"])
infinite_loop_canary -= 1
if infinite_loop_canary < 0:
break
The line in the script - reviews_resource.list(packageName=package_name,maxResults=100).execute()- is throwing "The caller does not have permission"
I am not exactly sure what needs to be done. Any help is appreciated.
I am posting the answer here since it took quite some time for me to figure this out, maybe it'll help someone else.
What you need before:
Service account from https://console.developers.google.com
A private key for the SA. (used .p12 file)
In Play Console, we need to grant access to this SA from Developer account -> API access.
Once we click on Grant Access(from step 3), we have Permissions dialog - enable "Reply to reviews" for the required apps.
The permissions created the issue from me.