【问题标题】:Downloading playstore statistics programmatically - Control access to Google Cloud Storage以编程方式下载 Playstore 统计信息 - 控制对 Google Cloud Storage 的访问
【发布时间】: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


    【解决方案1】:

    代码没问题。根据 google play 开发者支持团队的说法(感谢他们的及时支持),我们需要等待 24 小时后在 Play 控制台上邀请/添加服务帐户。

    等待推荐的时间后,我们可以从存储桶中下载数据。

    【讨论】:

    • 非常感谢!我花了几个小时调试它,并认为这是一些 IAM 设置问题,直到我看到你的帖子。所以我等待,然后第二天它可以正常工作,没有 403 错误。
    猜你喜欢
    • 1970-01-01
    • 2020-07-13
    • 2021-11-14
    • 2013-11-06
    • 2021-02-18
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    相关资源
    最近更新 更多