我有一个 Google Workspace Marketplace 应用程序,想确定哪些域已从我的网络应用程序(用 Java 编写,部署在 GAE)中安装或卸载它。
我已经从控制台启用了 GSuite Marketplace API 和 Google Workspace Marketplace SDK。在调用相关的 google服务时,我使用的是我用来列出我的市场应用程序的 GCP 项目。但我不断收到“未授权访问应用程序 ID”403 错误。这是代码:
GoogleCredential googleCredential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountPrivateKey(SA_PRIVATE_KEY)
.setServiceAccountId(SA_ID)
.setServiceAccountScopes(Collections.singletonList("https://www.googleapis.com/auth/appsmarketplace.license"))
.build();
GenericUrl url = new GenericUrl("https://appsmarket.googleapis.com/appsmarket/v2/licenseNotification/" + MY_APPLICATION_ID);
HttpRequestFactory httpRequestFactory = httpTransport.createRequestFactory(googleCredential);
HttpResponse httpResponse = httpRequestFactory.buildGetRequest(url).execute();
return httpResponse.parseAsString();
我尝试使用默认服务帐户,但没有成功。该文档也没有解释太多。我错过了什么?谁能指出我正确的方向?
错误:
{
"error": {
"code": 403,
"message": "Not authorized to access the application ID",
"errors": [
{
"message": "Not authorized to access the application ID",
"domain": "global",
"reason": "forbidden"
}
]
}
}