Google Sheets API返回“调用者没有权限”当使用服务器密钥时 [英] Google Sheets API returns "The caller does not have permission" when using server key

查看:727
本文介绍了Google Sheets API返回“调用者没有权限”当使用服务器密钥时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在API管理器中生成了一个服务器密钥,并试图在我的Mac上执行以下操作:

  curl' https://sheets.googleapis.com/v4/spreadsheets/MySheetID?ranges=A1:B5&key=TheServerKeyGeneratedInAPIManager'

但这是它返回的结果:

  {
错误:{
code:403,
message:调用者没有权限,
status:PERMISSION_DENIED
}
}

我在这里做错了什么?

解决方案 div>

我知道答案有点迟,但是对于同样问题的其他人也是如此。

只需将工作表的权限更改为公开即可因此无需通过API调用进行身份验证即可访问它。



更改访问权限:


  1. 在Google Drive中打开表格

  2. 在右上角点击分享

  3. 在提示窗口的底部,点击高级

  4. 将权限更改为公共或人员带有链接(无需登录)

发送API请求以从工作表中获取数据而无需身份验证。



注意:如果工作表包含敏感数据,那么将其公开化并不安全,而是通过身份验证访问进行。

I've generated a server key in the API Manager and attempted to execute the following on my Mac:

curl 'https://sheets.googleapis.com/v4/spreadsheets/MySheetID?ranges=A1:B5&key=TheServerKeyIGeneratedInAPIManager'

But this is what it returns:

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

What am I doing wrong here?

解决方案

I know it is a little late to answer but for other people struggling with the same issue.
Just change the permission of the sheet to public on your drive so it can be accessed without authentication via API calls.

To change access:

  1. Open sheet in google drive
  2. On top right corner, click share
  3. On bottom of prompt window, click advanced
  4. Change permission to public or people with link (no signin required)

Send API request to fetch data from sheets without authentication.

Note: if the sheet contains sensitive data then it is not safe to make it public and rather do it with Authenticated access.

这篇关于Google Sheets API返回“调用者没有权限”当使用服务器密钥时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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