我正在尝试列出我的应用程序的所有域安装。
为此我:
Google Apps Marketplace API
和 Apps Marketplace SDK
;Apps Marketplace SDK
(添加范围:"https://www.googleapis.com/auth/appsmarketplace.license"
);我总是遇到同样的 403 错误:
{
"error": {
"errors":[{
"domain": "global",
"reason": "forbidden",
"message": "Not authorized to access the application ID"
}],
"code":403,"message":"Not authorized to access the application ID"
}
}
有人可以解释一下我在这里想念什么吗?
我添加了更多角色:项目浏览器和项目查看器。他们中的任何一个或他们都似乎已经解决了问题。
对我有用的是使用具有
Basic Editor
角色的服务帐户。任何其他特权较低的角色都不起作用,因此它至少必须是编辑者或所有者。然后,我必须关注@A。 R. Younce 回答类似问题:
在服务帐号的“详细信息”选项卡上,展开“高级设置”部分,然后点击“创建与 Google Workspace Marketplace 兼容的 OAuth 客户端”按钮。
它并没有立即起作用。我不得不等待 20 分钟才能传播此更改。
这是要测试的示例 Python 脚本:
import os
from google.oauth2 import service_account
from googleapiclient.discovery import build
# Set the path to your service account key file
KEY_FILE_PATH = 'path/to/service-account.json'
# Set the scopes required for the API
SCOPES = ['https://www.googleapis.com/auth/appsmarketplace.license']
def create_service():
credentials = service_account.Credentials.from_service_account_file(KEY_FILE_PATH, scopes=SCOPES)
service = build('appsmarket', 'v2', credentials=credentials, static_discovery=False)
return service
def list_license_notifications():
service = create_service()
# Set your application ID
application_id = '<application-id>'
# Set the maximum number of results to retrieve (optional)
max_results = 100
# Make the API request
response = service.licenseNotification().list(
applicationId=application_id, max_results=max_results
).execute()
# Print the license notifications
notifications = response.get('notifications', [])
if notifications:
for notification in notifications:
print(notification)
else:
print('No license notifications found.')
if __name__ == '__main__':
list_license_notifications()
应用程序 ID 可在 Google Workspace Marketplace SDK 页面的 应用配置 选项卡
找到