Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何从应用程序脚本访问Google Apps Marketplace用户许可证(对于工作表附加组件)?_Google Apps Script_Google Apps Marketplace - Fatal编程技术网

Google apps script 如何从应用程序脚本访问Google Apps Marketplace用户许可证(对于工作表附加组件)?

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

我有一个Sheets附加组件,我需要从GAM(
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())
}