问题描述
我有一个 Google Workspace Marketplace 应用,想确定哪些域在我的网络应用中安装或卸载了它(用 Java 编写,部署在 GAE 上)。
我已从控制台启用 GSuite Marketplace API 和 Google Workspace Marketplace SDK。我使用的 GCP 项目与我在调用相关谷歌 service 时用于列出我的市场应用程序的相同。但我不断收到“未授权访问应用程序 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();
我尝试使用默认服务帐户,但没有成功。 documentation 也没有太多解释。我错过了什么?有人能指出我正确的方向吗?
错误:
{
"error": {
"code": 403,"message": "Not authorized to access the application ID","errors": [
{
"message": "Not authorized to access the application ID","domain": "global","reason": "forbidden"
}
]
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)