【发布时间】:2021-11-30 08:26:10
【问题描述】:
我正在尝试使用 python [source] 下载 google play 控制台报告。 - 请注意,“SignedJwtAssertionCredentials”库不再可用,根据我的搜索重命名为“ServiceAccountCredentials”。我在下面附上我的代码:
import json
import os
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient.discovery import build
jsonfile = os.path.join(
os.path.dirname(__file__), 'private_key.json')
client_email = 'abce@api-*********-*****.iam.gserviceaccount.com'
json_file = jsonfile
cloud_storage_bucket = 'pubsite_prod_rev_***********'
report_to_download = 'earnings/earnings_201811_*********-*.zip'
private_key = json.loads(open(json_file).read())['private_key']
credentials = ServiceAccountCredentials(client_email, private_key,'https://www.googleapis.com/auth/devstorage.read_only')
storage = build('storage', 'v1', http=credentials.authorize(Http()))
result = storage.objects().get(bucket =cloud_storage_bucket,object =report_to_download).execute()
print(result)
我面临的错误: Error Snapshot
另一方面,我可以使用 .net source 成功访问数据,因此不存在权限问题。 而且我认为 ServiceAccountCredentials 参数有问题,这就是它无法进行签名 jwt 的原因。
其他细节: 蟒蛇:3.9.5 谷歌云存储:1.43.0 谷歌身份验证:2.3.3
我知道这个问题太长了,但如果有人能提供帮助,那就太好了。谢谢
【问题讨论】:
标签: python google-cloud-storage