【发布时间】:2020-04-06 16:46:03
【问题描述】:
我使用谷歌应用脚本为谷歌电子表格构建了一个插件,但我不明白为什么它会要求云端硬盘权限。
Drive API 未启用,我没有在项目中的任何地方使用DriveApp 类,driveapp 范围也没有在任何地方定义,但它显示在 OAuth 授权屏幕中并使应用程序未经验证:
appscript.json 文件中定义的范围:
"oauthScopes": [
"https://www.googleapis.com/auth/analytics.edit",
"https://www.googleapis.com/auth/analytics.readonly",
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/script.send_mail",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/userinfo.email"
]
【问题讨论】:
-
Google 电子表格是云端硬盘的一部分。此链接显示所需的 OAuth 范围:developers.google.com/sheets/api/guides/authorizing
-
你看过this Stackoverflow吗?您可以在评论中使用 DriveApp。如果不是这种情况,请尝试一个一个删除范围,您会看到哪个请求驱动器权限。我会从
https://www.googleapis.com/auth/script.storage开始,它可能会在用户的 Google Drive 中存储脚本,从而要求 Drive 权限 -
@jwilleke 是否意味着不需要在 OAuth 同意屏幕中验证
driveapp范围? -
您能否提供代码以查看对云端硬盘的调用可能来自何处?
-
@ziganotschka 代码很大,减少它会很痛苦。我将尝试一个一个删除范围并查看它我可以通过这种方式找出问题。
标签: google-apps-script google-cloud-platform oauth scopes