【问题标题】:Downloading google play store reports programmatically using python使用 python 以编程方式下载 google play 商店报告
【发布时间】: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


    【解决方案1】:

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

    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')
    

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

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

    我希望这个例子可以在将来对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-05
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多