使用 python 以编程方式下载 google Play 商店报告

Downloading google play store reports programmatically using python

我正在尝试使用 python [source] 下载 google 播放控制台报告。 - 请注意,“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 成功访问数据,因此没有权利问题。 而且我认为 ServiceAccountCredentials 参数有问题,这就是为什么它无法制作签名的 jwt。

其他详情: python:3.9.5 google-云存储:1.43.0 google-授权:2.3.3

我知道这个问题太长了,但如果有人能提供帮助就太好了。谢谢

我通过更改自己修复了错误 这个

ServiceAccountCredentials(client_email, private_key,'https://www.googleapis.com/auth/devstorage.read_only')

至此

ServiceAccountCredentials.from_json_keyfile_name(json_file,'https://www.googleapis.com/auth/devstorage.read_only')

虽然错误消失了,但结果不是我所期望的。它返回了桶的某种元数据,例如:timeCreated、storageClass、id等。

因此,为了获得我想要的结果,我改变了方法并编写了另一段代码here。此代码从 google 云存储获取数据到 s3 存储桶。

希望这个例子对以后的人有所帮助。