使用appscript跟踪用户安装的谷歌市场应用程序



我们使用AppsScript开发了一个谷歌市场应用程序,现在已经在市场上运行(https://workspace.google.com/marketplace/app/report_connector_for_salesforce_beta/977246938879)。然而,我们正在努力解决如何使用谷歌市场API(https://developers.google.com/workspace/marketplace/example-calls-marketplace-api)以访问许可证数据。其他人成功地做到了吗?

有其他人成功地做到了吗?顺便说一句,如果市场上有这样的应用程序,那就太好了!

非常感谢

Andy

到目前为止,我们已经创建了一个单独的Google Sheet(与我们的应用程序位于同一域),并编写了一个简单的API调用函数,如下所示:

function getUsers() {
const options = {
muteHttpExceptions: true,
headers: {
Authorization: `Bearer ${ScriptApp.getOAuthToken()}`
}
};
let response = UrlFetchApp.fetch("https://appsmarket.googleapis.com/appsmarket/v2/licenseNotification/<our app Id>",options); 
Logger.log("Refresh Response:"+response); 
}

我们在GCP中创建了一个新项目,并启用了:Google Workspace市场API
Google Workspace市场SDK

我们在项目中添加了以下范围:

连接到外部服务https://www.googleapis.com/auth/script.external_request查看已安装的应用程序的许可信息https://www.googleapis.com/auth/appsmarketplace.license

但是,当我们运行代码时,我们只会得到以下内容:

Info    Refresh Response:{
"error": {
"code": 403,
"message": "Not authorized to access the application ID",
"errors": [
{
"message": "Not authorized to access the application ID",
"domain": "global",
"reason": "forbidden"
}
]
}
}

这对我有效,但我需要添加"https://*.googleapis.com/";在CCD_ 2中。

你的应用程序Id正确吗?查看https://console.cloud.google.com/apis/api/appsmarket-component.googleapis.com/googleapps_sdk?project=*项目名称*

相关内容

最新更新