Google apps script 如何从应用程序脚本访问Google Apps Marketplace用户许可证(对于工作表附加组件)?
我有一个Sheets附加组件,我需要从GAM(Google apps script 如何从应用程序脚本访问Google Apps Marketplace用户许可证(对于工作表附加组件)?,google-apps-script,google-apps-marketplace,Google Apps Script,Google Apps Marketplace,我有一个Sheets附加组件,我需要从GAM(appsmarket/v2/userLicense)了解用户许可证信息。由于用户已经登录到工作表中,我不希望需要使用OAuth,但我收到一条403(“消息”:“未授权访问应用程序ID”)。有没有一种方法可以在不使用OAuth的情况下从应用程序脚本访问许可证?以下是我目前的代码: function testGetLicense(query) { var options = { 'method' : 'get', 'conten
appsmarket/v2/userLicense
)了解用户许可证信息。由于用户已经登录到工作表中,我不希望需要使用OAuth,但我收到一条403(“消息”:“未授权访问应用程序ID”
)。有没有一种方法可以在不使用OAuth的情况下从应用程序脚本访问许可证?以下是我目前的代码:
function testGetLicense(query) {
var options = {
'method' : 'get',
'contentType': 'application/json',
'muteHttpExceptions' : true
};
var url = 'https://www.googleapis.com/appsmarket/v2/userLicense/1234/xxx@gmail.com'
res = UrlFetchApp.fetch(url, options);
Logger.log(res.getContentText())
}
如果我需要使用OAuth,我应该使用这个库吗
尝试在标头中传递OAuth令牌
function testGetLicense(query) {
var options = {
'method' : 'get',
'contentType': 'application/json',
'headers': {
"Authorization": "Bearer " + ScriptApp.getOAuthToken()
},
'muteHttpExceptions' : true
};
var url = 'https://www.googleapis.com/appsmarket/v2/userLicense/1234/xxx@gmail.com'
res = UrlFetchApp.fetch(url, options);
Logger.log(res.getContentText())
}