我在谷歌云项目下创建了一个服务帐户,而不是使用默认帐户,我启用了dwd。
然后,我从Google云端控制台启用了Google Apps Marketplace API
。
然后我发布了一个只适用于我的GSuite域用户的市场应用程序,其中manifest.json中的api_console_project_id
设置为我项目的ID。
开发人员信息中心中的status
是
Published
GAM: Pending
然后我让我的域管理员安装了应用程序。
我相信我现在已准备好使用appsmarket v2 Python客户端来验证我的域名的许可证。
以下是我的工作方式
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
path_to_key = 'path/to/my/service_account_key.json'
scopes = ['https://www.googleapis.com/auth/appsmarketplace.license']
APPLICATION_ID = 'xxxxxxxxxxxx'
domain = 'xxxxxx.com'
credentials = ServiceAccountCredentials.from_json_keyfile_name(
path_to_key, scopes)
authorized_http = credentials.authorize(Http())
appsmarket_api_client = build(
'appsmarket', 'v2', http=authorized_http)
appsmarket_license_info = appsmarket_api_client.customerLicense().get(
applicationId=APPLICATION_ID, customerId=domain).execute()
domain_is_licensed = (appsmarket_license_info['state'] == 'ACTIVE')
但我的代码在
处断开appsmarket_license_info = appsmarket_api_client.customerLicense().get(
applicationId=APPLICATION_ID, customerId=domain).execute()
HttpError 403 when requesting https://www.googleapis.com/appsmarket/v2/customerLicense/xxxxxxxxxxxx/xxxxxx.com?alt=json returned "Not authorized to access the application ID
我无法调试为什么会发生这种情况。
答案 0 :(得分:2)
我错过的是我没有将服务帐户添加为项目成员并授予其对项目的编辑权限。现在它正在发挥作用。