【问题标题】:Google Script Add-on requires access for an unused scopeGoogle Script Add-on 需要访问未使用的范围
【发布时间】: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 Cloud Platform 中授权的范围,OAuth 同意屏幕:

【问题讨论】:

  • 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


【解决方案1】:

正如 Google 表格的 documentation 中所写,如果您不使用公共数据,您只需很少的云端硬盘授权即可使用 API。

https://www.googleapis.com/auth/drive.readonly

https://www.googleapis.com/auth/drive.file

https://www.googleapis.com/auth/drive(仅在绝对必要时才请求此范围。)

【讨论】:

  • 那么Drive权限不是使应用无法验证的那个,肯定还有别的
【解决方案2】:

似乎我在 G Suite Marketplace 配置中添加了 driveapp 范围,并且 OAuth 屏幕在删除该范围后不再要求驱动器权限。 “未验证”应用消息也不再显示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多