Google Sheets API:调用者没有权限 [英] Google Sheets API: The caller does not have permission

查看:257
本文介绍了Google Sheets API:调用者没有权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从cron读取文档:

I'm trying to read the document from the cron:

https://sheets.googleapis.com/v4/spreadsheets/<sheet_id>?key=<api_key>

任何链接的人都可以使用我的文档.

My document is available to anyone with the link.

My #1 key settings:    
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - none


My #2 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - Google Sheets API


My #3 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - Google Sheets API, Google Drive API


My #4 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - Google Sheets API


My #5 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - Google Sheets API, Google Drive API


My #6 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - none


当我尝试使用每个键打开文档时,出现403错误:


When I try to open a document with each key, I get a 403 error:

{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
  }
}

使用API​​资源管理器( https: //developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get ).

The same error occurs when using the API Explorer (https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get).

同时,文档本身可以通过任何计算机和任何浏览器的链接成功打开,甚至可以打开未授权用户的链接.

At the same time, the document itself opens successfully from a link from any computer and from any browser even to unauthorized users.

此问题始于7月9日下午9:35(UTC + 0).

This problem began on July 9 at 09:35 PM (UTC+0).

在发生此错误之前,我已经使用#1 key settings成功地从文档中接收了数据.

Prior to this error, I successfully received data from the document using the #1 key settings.

更新:

我发现了另一个奇怪的细微差别:在所有其他文档上都没有这样的问题.在一个特定的文档上观察到错误.我将访问设置与其他访问设置进行了比较-它们是相同的.

I found another strange nuance: on all other documents there is no such problem. An error is observed on one particular document. I compared the access settings with others - they are identical.

更新2:

我试图复制该表并通过API打开它-错误是相同的. 一个小时后,我再次尝试-一切正常.

I tried to copy the table and open it via API - the error was the same. An hour later I tried again - it all worked.

推荐答案

看到 HoverPhoenix 评论后,我更改了在查看器模式下将我的工作表发送给**任何具有链接的人**.

After seeing HoverPhoenix comment, I change access of My sheet to ** Anyone with link** on Viewer mode.

更改访问权限后,它可以正常工作.如果需要考虑数据安全性,那么最好的选择是使用OAuth 2.0客户端ID作为凭据.

After changing the access it is working properly. If Data security is the concern then the best option is to use OAuth 2.0 Client IDs as credentials.

这篇关于Google Sheets API:调用者没有权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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