【问题标题】:What is the most feasible way to authenticate using OAUTH2.0 in appscript?在 appscript 中使用 OAUTH2.0 进行身份验证的最可行方法是什么?
【发布时间】:2019-04-14 12:31:22
【问题描述】:

代码示例:

var propertyStore = PropertiesService.getScriptProperties();

//Logger.log(DriveApp.getFileById('1c4azrEgTFk7ujAF7dn2SL3whXEnTF6Mg'));

cGoa.GoaApp.setPackage(propertyStore,
    cGoa.GoaApp.createServiceAccount (DriveApp , {
    packageName: 'mypackage',
    fileId: '1c4azrEgTFk7ujAF7dn2SL3whXEnTF6Mg',
    scopes: cGoa.GoaApp.scopesGoogleExpand(['https://www.googleapis.com/auth/devstorage.full_control']),
    service: 'google_service'
    }));

但没有注释行会显示错误:

您无权调用 DriveApp.getFileById。所需权限:https://www.googleapis.com/auth/drive(第 256 行,文件“GoaApp”,项目“cGoa”)”

【问题讨论】:

    标签: google-apps-script oauth-2.0


    【解决方案1】:

    由于某种原因,无法打开同意对话框供您(脚本创建者)进行授权。要做到这一点,请添加一个调用 DriveApp 的函数并运行它。然后应该向您显示同意屏幕以进行授权。然后就可以运行oneoff函数了。

    function runThenDeleteMe() {
      DriveApp.getFiles();
    }
    

    【讨论】:

      猜你喜欢
      • 2020-06-27
      • 2013-12-08
      • 2012-09-04
      • 2011-03-06
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 2010-09-06
      相关资源
      最近更新 更多