使用drive.file范围将行追加到Google表格

时间:2020-05-13 15:23:23

标签: google-sheets google-drive-api google-oauth

是否可以使用drive.file范围将行追加到现有的Google表格中?

https://www.googleapis.com/auth/drive.file范围定义为

按文件访问由应用创建或打开的文件

Sheets docs

按文件访问由应用程序创建或打开的文件。文件 授权是按用户授予的,并且在 用户取消对应用程序的授权

Drive docs中。

Google由应用“打开”是什么意思?打开不是API中的方法。

我已经构建了一个使用drive.file范围的应用程序,该应用程序可以很好地验证和接收令牌。当我尝试将行添加到现有工作表时,API响应为404。

如果我使用更广泛的范围https://www.googleapis.com/auth/spreadsheets对同一应用程序进行身份验证,则该应用程序可以轻松地将行追加到同一工作表。我不想使用需要应用程序验证的更广泛的范围,因为该应用程序是基于OAuth的插件,是一种应用程序Google says should not require Sensitive or Restricted scopes or verification。我的应用也符合Google建议的drive.file范围here的标准。

我发现所有这些问题都是重复的,没有明确的答案:

  1. Request specific file permissions with Google Sheets / Google Drive API
  2. AuthToken for drive.file scope returning 404
  3. Getting Google file picker to work with drive.file scope
  4. How to use the scope https://www.googleapis.com/auth/drive.file correctly
  5. Is there anyway to get private file of user with drive.file scope
  6. Is the https://www.googleapis.com/auth/drive.file enough to create and update files or is the scope /drive needed?

1 个答案:

答案 0 :(得分:0)

我的结论是不,这是不可能的。我将我的应用程序设计为有一个“创建工作表”按钮作为解决方法,并且 drive.file 范围可以很好地附加行并对我的应用程序创建的工作表进行其他编辑。