以编程方式下载 Playstore 统计信息 - 控制对 Google 云存储的访问

Downloading playstore statistics programmatically - Control access to Google Cloud Storage

我正在尝试以编程方式(使用服务帐户和客户端库)从 google 播放控制台下载应用程序安装统计信息。

我正在关注文档 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 云存储 的访问。说的部分:

“查看应用信息”权限必须设置为“全局”。 (我不确定如何设置它。)

下面是我的代码(和文档里的一样)

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

任何支持都会有很大帮助!

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

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