提供的范围不足以访问该文档。要访问它,您还需要文档范围。编辑清单文件以具有以下范围:
"oauthScopes": ["https://www.googleapis.com/auth/script.external_request","https://www.googleapis.com/auth/documents"],
或者在脚本中添加对 Document App 的虚拟调用:
DocumentApp.getActiveDocument();
根据评论Tanaike https://stackoverflow.com/users/7108653,似乎文档范围还不够,但电子表格范围也是需要的,即使我们不访问电子表格。或者,需要 Drive 的只读范围。
电子表格+文档范围:
显现:
"oauthScopes": ["https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/documents"
"https://www.googleapis.com/auth/spreadsheets"],
或者在脚本中添加对 Document App+SpreadsheetApp 的虚拟调用:
//DocumentApp.getActiveDocument();
//SpreadsheetApp.getActive();
驱动范围:
显现:
"oauthScopes": ["https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/drive.readonly"],
或者在脚本中添加对 DriveApp 的虚拟调用:
//DriveApp.getFiles()