我想根据电子表格中的电子邮件撤消对Google云端硬盘中文件夹和文件的访问权限。但是获取文件夹/文件时出了点问题。
错误:
异常:您无权调用DriveApp.getFolders。 所需权限:https://www.googleapis.com/auth/drive
我尝试添加范围:
scopesFile = {
"oauthScopes": [
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/spreadsheets"
]
}
但是即使那样也无济于事...是否可以强制脚本重新授权?
function revokeGoogleDriveAccess(email, ui){
const folders = DriveApp.getFolders();
const files = DriveApp.getFiles();
while(folders.hasNext()){
var folder = folders.next();
folder.revokePermissions(email);
}
while(files.hasNext()){
var file = files.next();
file.revokePermissions(email);
}
}
function onEdits(e) {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var email = ss.getRange("J" + rowLineNumber).getValue();
revokeGoogleDriveAccess(email, ui); // <-- Google Drive Permissions Are Revoked Here.
}
我希望它撤消访问权限,但我在DriveApp.getFolders() / DriveApp.getFiles()
停了下来