【发布时间】:2021-10-24 16:44:32
【问题描述】:
我正在尝试以编程方式从 google play 控制台下载应用安装统计信息(使用服务帐户和客户端库)。
我正在关注文档here。
当我运行代码时,我收到以下错误:
<HttpError 403 when requesting https://storage.googleapis.com/storage/v1/b/pubsite_prod_rev_xxxx/o/installs_com.xxx.xxx_201701_overview%2A?alt=json returned "xxxx@xxxx.iam.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object.". Details: "[{'message': 'xxxx@xxxx does not have storage.objects.get access to the Google Cloud Storage object.', 'domain': 'global', 'reason': 'forbidden'}]">
我没有从文档中明确做的唯一事情是标题下的那一项:
控制对 Google Cloud Storage 的访问权限。说的部分:
“查看应用信息”权限必须设置为“全局”。 (我不确定如何设置。)
以下是我的代码(与文档中的相同)
client_email = 'xxxx@xxxx.com'
json_file = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
report_to_download = 'installs_com.xxx.xxxx_201701_overview*'
private_key = json.loads(open(json_file).read())['private_key']
credentials = SignedJwtAssertionCredentials(client_email, private_key,'https://www.googleapis.com/auth/devstorage.read_only')
storage = build('storage', 'v1', http=credentials.authorize(Http()))
print (storage.objects().get(bucket=cloud_storage_bucket,object=report_to_download).execute())
任何支持都会有很大帮助!
【问题讨论】:
标签: android google-cloud-platform google-play-console google-api-python-client