gspread authentication throwing insufficient permission(gspread 身份验证抛出权限不足)
问题描述
使用 developers.google.com 我们创建了 api 用户并将凭据下载为 json 文件.现在在我的 macbook 上,gspread 身份验证在使用 credentials.json 时工作正常.当将相同的配置移动到 aws 上的 linux 服务器时,会出现 403 权限不足错误.
Using developers.google.com we created api user and downloaded credentials as json file. Now On my macbook gspread authentication is working fine while using credentials.json. when moved same config to linux server on aws its giving 403 insufficient permission error.
pip 和 python 版本相同.
Pip and python version are same.
例外
gspread.v4.exceptions.APIError: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
基本代码
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
sheet = client.open('MySheetName').sheet1
推荐答案
尝试将您的 scope
变量更改为以下内容:
Try to change your scope
variable to the following:
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
确保在 API 控制台中启用 Drive API.
Make sure Drive API is enabled in API console.
gspread 已升级,现在基于 API v4.它更快,但需要范围内的更新.
gspread has been upgraded and it's now based on API v4. It's faster but it requires updates in scope.
同样的问题:https://github.com/burnash/gspread/issues/512
这篇关于gspread 身份验证抛出权限不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:gspread 身份验证抛出权限不足


- pytorch 中的自适应池是如何工作的? 2022-07-12
- 沿轴计算直方图 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01