【问题标题】:How to access a different Google Drive using Google Scripts如何使用 Google Scripts 访问不同的 Google Drive
【发布时间】:2019-04-05 18:09:48
【问题描述】:

我是一名讲师。我与学生共享一个模板电子表格。我想要一个函数,它将 template_spreadsheet 作为 student_spreadsheet 复制到学生的本地驱动器,然后让该函数编辑 student_spreadsheet。我不知道该怎么做。

我查看了这段代码:How to copy google drive folder into another google drive account by using App Script?,它与我的问题类似,但是在不知道目标文件夹的情况下,该代码仍然没有显示如何执行此操作(我需要弄清楚如何访问学生的驱动器)。

function createCopy(){
  var template_spreadsheet = SpreadsheetApp.openById(template_spreadsheet_id);
  var student_spreadsheet = template_spreadsheet_id.copy(template_spreadsheet.getName()); 
  return student_spreadsheet;
}

这显然只是将模板复制到我自己的 Google Drive。我希望它复制到我与之共享的学生的 Google 云端硬盘中。

【问题讨论】:

  • 您不能在其他人的驱动器中写入/创建新文件,但根据您的用例,您是否考虑过让他们(学生)成为工作表的所有者?让我知道这是否可行,以便我们帮助编写相应的脚本。

标签: google-apps-script google-drive-api


【解决方案1】:

要访问“不同的驱动器”,您可以使用 OAuth,但首先您应该让其他用户授权您的脚本执行此操作,或者如果您使用 G Suite 帐户,您应该要求 G Suite 域管理员启用域- 广泛的授权。

【讨论】:

    猜你喜欢
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多