我正在尝试列出在 google-api-python-client 的帮助下上传到 Firebase App Distribution 的构建,但是我总是收到 HTTP 状态代码 400。
我创建了一个具有完全所有者权限的
service-account.json
(用于测试)project_id
。app_id
。
我的Python脚本:
import os
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
script_dir = os.path.dirname(os.path.abspath(__file__))
service_account_file = os.path.join(script_dir, 'service-account.json')
credentials = service_account.Credentials.from_service_account_file(service_account_file)
project_id = credentials.project_id
app_id = "1:310501947997:android:4f5183af1eddc4004eabb4"
service = build('firebaseappdistribution', 'v1', credentials=credentials)
try:
parent = f"projects/{project_id}/apps/{app_id}"
app_releases = service.projects().apps().releases().list(parent=parent).execute()
print(app_releases)
except HttpError as e:
print('Error response status code : {0}, reason : {1}'.format(e.status_code, e.error_details))
错误响应状态代码:400,原因:请求包含无效参数。
有人知道哪个参数无效导致 HTTP 400 吗?
您的代码正在使用
Project ID
。该 API 需要指定 Project Number
。
有关所需参数的更多详细信息,请参阅此文档: