“PERMISSION_DENIED"在 Google 电子表格 REST API v4 上 [英] "PERMISSION_DENIED" on Google Spreadsheet REST API v4

查看:24
本文介绍了“PERMISSION_DENIED"在 Google 电子表格 REST API v4 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过 http 从谷歌表中读取数据.我使用 v4 谷歌电子表格 API:

I try to read data from google sheet via http. I use v4 google spreadsheet api:

https://sheets.googleapis.com/v4/spreadsheets/1MZJEOzkzy5iJ9HPy2GU-Ky3vdaIzGGDQH8BMt4n3OGI/values/Sheet1!A1:D5

我明白了:

{
  "error": {
    "code": 403,
    "message": "The request cannot be identified with a client project. Please pass a valid API key with the request.",
    "status": "PERMISSION_DENIED"
  }
}

工作表在线发布,每个人都可以编辑.它也适用于 api v3.

Sheet is published online and everyone can edit it. It works on api v3 too.

推荐答案

首先,请确保您有权调用此电子表格,并在开发者控制台中启用 Sheets API.您也可以尝试将此电子表格的隐私设置更改为公开并检查您现在是否可以访问它.这个 403 错误通常是由于 Authorizing Requests 中的某些配置不正确或遗漏造成的.如果您使用 OAuth 2.0 授权请求,请确保使用正确的范围.

First, make sure you have a permission to call this spreadsheet and you enable the Sheets API in your developer console. You can also try to change the privacy settings of this spreadsheet to public and checked if you can access it now. This 403 error is usually caused by incorrect or missed some configuration in Authorizing Requests. If you authorizing requests with OAuth 2.0, make sure you use the proper scope with it.

有关更多信息,您可以查看此thread 关于如何在收到 HTTP 401s 或 403s 时调试 Google OAuth 2.0 令牌

For more information, you can check this thread on how to debug your Google OAuth 2.0 token when you get HTTP 401s or 403s

这篇关于“PERMISSION_DENIED"在 Google 电子表格 REST API v4 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆