我是电子表格所有者的电子表格出现“请求的身份验证范围不足”错误

时间:2019-04-11 23:03:19

标签: google-sheets gapi

当我尝试访问一个公开的,共享的电子表格(我拥有)时,出现以下错误。 但仅当我登录到我的Google帐户后

如果我尝试从隐身模式标签访问电子表格,则可以正常阅读电子表格。

为什么会这样?

我正在使用google-api-javascript-client/1.1.0导入的<script async defer src="https://apis.google.com/js/api.js"></script>

这是错误:

{
    "result": {
        "error": {
            "code": 403,
            "message": "Request had insufficient authentication scopes.",
            "status": "PERMISSION_DENIED"
        }
    },
    "body": "{\n  \"error\": {\n    \"code\": 403,\n    \"message\": \"Request had insufficient authentication scopes.\",\n    \"status\": \"PERMISSION_DENIED\"\n  }\n}\n",
    "headers": {
        "date": "Thu, 11 Apr 2019 22:51:12 GMT",
        "content-encoding": "gzip",
        "www-authenticate": "Bearer realm=\"https://accounts.google.com/\", error=\"insufficient_scope\", scope=\"https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.resource https://www.googleapis.com/auth/spreadsheets https://spreadsheets.google.com/feeds https://spreadsheets.google.com/feeds/ http://spreadsheets.google.com/feeds http://spreadsheets.google.com/feeds/ https://spreadsheets.google.com/feeds/spreadsheets https://spreadsheets.google.com/feeds/spreadsheets/private/full http://spreadsheets.google.com/feeds/spreadsheets/private/full https://spreadsheets.google.com/feeds/worksheets/ https://spreadsheets.google.com/tq https://spreadsheets.google.com/feeds/list/ https://spreadsheets.google.com/feeds/worksheet/ https://spreadsheets.google.com/feeds/cell/ https://www.googleapis.com/auth/spreadsheets.readonly\"",
        "server": "ESF",
        "content-type": "application/json; charset=UTF-8",
        "vary": "Origin, X-Origin, Referer",
        "cache-control": "private",
        "content-length": "137"
    },
    "status": 403,
    "statusText": null
}

我用于读取电子表格的代码使用传递给gapi的以下值:

  • discoveryDocs = ["https://sheets.googleapis.com/$discovery/rest?version=v4"]
  • scope = "https://www.googleapis.com/auth/spreadsheets.readonly"

例如:

gapi.client.init({
  apiKey,
  clientId,
  discoveryDocs,
  scope,
});

0 个答案:

没有答案