深山夕照 2018-05-24 02:01 采纳率: 0%
浏览 807
已结题

Python访问Google Spreadsheet返回403错误

我想通过Python访问Google表单:

 import gspread
from oauth2client.service_account import ServiceAccountCredentials
import json
GDriveJSON = 'D:\毕业设计\PythonUpload.json'
GSpreadSheet = 'New Stories'
json_key = json.load(open(r'D:\毕业设计\PythonUpload.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(GDriveJSON, scope)
gc = gspread.authorize(credentials)

但是在打开的时候:

 ws = gc.open(GSpreadSheet).sheet1

返回了403错误:

 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Program Files\Python36\lib\site-packages\gspread\client.py", line 122, in open
    self.list_spreadsheet_files()
  File "D:\Program Files\Python36\lib\site-packages\gspread\client.py", line 96, in list_spreadsheet_files
    res = self.request('get', url, params=params).json()
  File "D:\Program Files\Python36\lib\site-packages\gspread\client.py", line 79, in request
    raise APIError(response)
gspread.exceptions.APIError: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}

请问应该怎么修改呢?

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-05-24 02:51
    关注

    403是权限问题(Insufficient Permission,权限不足),credentials 这个检查下。

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题