【发布时间】:2018-08-21 20:24:54
【问题描述】:
使用 developers.google.com 我们创建了 api 用户并将凭据下载为 json 文件。 现在在我的 macbook 上,gspread 身份验证在使用 credentials.json 时工作正常。当将相同的配置移动到 aws 上的 linux 服务器时,会出现 403 权限不足错误。
pip 和 python 版本相同。
例外
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
【问题讨论】:
-
我在我的两台 linux 服务器中的一台上看到了类似的问题。我目前在我的服务器之间唯一的区别是他们安装了什么版本的 gspread,也许检查一下你的两台机器正在使用什么版本的 gspread?请告诉我你是如何解决的!
-
我在我的 linux 服务器上回滚了 gspread 的版本,它遇到了同样的问题,这似乎已经解决了我的问题,暗示 gspread 2.0 可能是罪魁祸首,希望你是一个类似的问题.这就是我运行的: pip install 'gspread==0.6.2' --force-reinstall
标签: python google-drive-api google-spreadsheet-api gspread