使用多个帐户验证应用程序脚本



在Google驱动器中,我试图将文件夹从个人帐户(帐户a)复制到公司工作空间帐户(帐户B)。

我正在尝试运行脚本,credit to ref

/**
* Entry point to execute with the Google Apps Script UI
*/
function copyFolder() {
// Get the folders (by ID in this case)
sourceID = "xxxxxxxxxx"
targetID="xxxxxxxxx
const toCopy = DriveApp.getFolderById(sourceID )      
const copyInto = DriveApp.getFolderById(targetID) //error in  this line 
// Call the function that copies the folder
copyFolder_(toCopy, copyInto)
}

我正在尝试以帐户A中的用户运行此脚本。出现如下错误

Exception: No item with the given ID could be found. Possibly because you have not edited this item or you do not have permission to access it.

原因是targetID引用到Account b中的文件夹

如何授予ACCOUNT A用户在ACCOUNT B中放置某些东西的权利?

您正在使用Google Apps Script UI,所以我认为文件夹targetID不会改变(经常),对吧?

此时只需提前向B帐号申请targetID文件夹权限即可。

相关内容

最新更新