为什么我的 Google Apps 脚本权限几天后就被撤销了?

Why my Google Apps Script permissions are revoked after few days?

我在 Google Apps 脚本的帮助下制作了一个简单的 Telegram 机器人 运行 在 Google 电子表格上。 它在工作表中进行查找,并可选择将上传的文件保存到我的 Google 驱动器。

以前它是附加到电子表格的脚本。后来 Google 建议在 Google Cloud Console 中创建一个应用程序并将脚本分配给该应用程序 ID,因此所有 API 调用都是负责任的。

脚本应用未经验证,运行处于“发布状态:测试”模式。我只需要它来访问我的帐户数据。

我授予脚本的权限(访问表格、云端硬盘)会在大约 2-3 天后自动撤销,恕不另行通知,并且机器人停止工作。直到我重新访问 Shpreadsheet,打开 Extensions - Apps Script,运行 any function,它再次要求授权。然后机器人又工作了几天。

如何使我授予的权限永久化?


我(再次)授予我的应用程序的权限:

更新了电子表格应用程序的菜单:

来自Setting up your OAuth consent screen > Testing

Authorizations by a test user will expire seven days from the time of consent. If your OAuth client requests an offline access type and receives a refresh token, that token will also expire.

考虑到上述情况,您必须让 Google 验证您的应用。