gpt4 book ai didi

python - 无法连接到 Google Playdeveloperreporting API

转载 作者:行者123 更新时间:2023-12-05 05:40:05 24 4
gpt4 key购买 nike

我正在尝试使用 Google Play Developer Reporting API v1beta1 导入 Android Vitals 统计信息。为此,我正在使用系统管理员创建的 service_account。但是,当脚本发送负载数据查询时,它会出现将 Google Cloud 与 Play Console 关联的错误,但管理员表示该帐户与 Google Play 关联。我在谷歌搜索但找不到同样的问题。请帮忙!

脚本:

from google.oauth2 import service_account
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials

SCOPES = ["https://www.googleapis.com/auth/playdeveloperreporting"]
credentials = service_account.Credentials.from_service_account_file('servise_account.json')
scoped_credentials = credentials.with_scopes(SCOPES)
reporting_user = build("playdeveloperreporting", "v1beta1", credentials=scoped_credentials, cache_discovery=False)

body = {"dimensions": ["versionCode"],
"metrics": ["anrRate", "anrRate7dUserWeighted", "distinctUsers"],
"timelineSpec": {"aggregationPeriod": "DAILY",
"endTime": {
"day": 16,
"month": 5,
"year": 2022
},
"startTime": {
"day": 10,
"month": 5,
"year": 2022
}}}

d = reporting_user.vitals().crashrate().query(name="apps/com.example.game/crashRateMetricSet", body=body).execute()
pprint(d)

错误文本:

Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1112, in _run_raw_task
self._prepare_and_execute_task_with_callbacks(context, task)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1285, in _prepare_and_execute_task_with_callbacks
result = self._execute_task(context, task_copy)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1315, in _execute_task
result = task_copy.execute(context=context)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/python.py", line 117, in execute
return_value = self.execute_callable()
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/python.py", line 128, in execute_callable
return self.python_callable(*self.op_args, **self.op_kwargs)
File "/opt/airflow/dags/anr_crash_share.py", line 89, in query
d = reporting_user.vitals().crashrate().query(name="apps/com.example.game/crashRateMetricSet", body=body).execute()
File "/home/airflow/.local/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/airflow/.local/lib/python3.8/site-packages/googleapiclient/http.py", line 915, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.game/crashRateMetricSet?alt=json returned "The linked Google Cloud project does not match the project used to call this API. Requests to the Google Play Developer Reporting API must use a service account or authenticate through an OAuth client belonging to the linked Cloud project.". Details: "The linked Google Cloud project does not match the project used to call this API. Requests to the Google Play Developer Reporting API must use a service account or authenticate through an OAuth client belonging to the linked Cloud project.">

最佳答案

您调用的服务帐户似乎不是在链接到 Google Play 帐户的项目中创建的。打开我在您的文件中看到的“servise_account.json”文件。检查那里的项目 id json 字段。它应该与 Google Play 中的项目匹配。

关于python - 无法连接到 Google Playdeveloperreporting API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72491524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com