【问题标题】:Python : connection failed after authentication success using PyDrivePython:使用 PyDrive 验证成功后连接失败
【发布时间】:2017-06-26 13:42:11
【问题描述】:

我正在使用 Python 版本 3 和 PyDrive 来连接 Google 电子表格。 我成功打开浏览器并进行身份验证。但是,在那之后我得到一个错误并且程序没有继续。

这是一条错误消息

Authentication successful.
Traceback (most recent call last):
File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/pydrive/files.py", line 369, in _FilesInsert
http=self.http)
File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/googleapiclient/http.py", line 812, in execute
_, body = self.next_chunk(http=http, num_retries=num_retries)
File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/googleapiclient/http.py", line 916, in next_chunk
raise ResumableUploadError(resp, content)
googleapiclient.errors.ResumableUploadError: <HttpError 403 "Project 895099846013 is not found and cannot be used for API calls. If it is recently created, enable Drive API by visiting then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "drive_control.py", line 10, in <module>
   file.Upload()
 File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/pydrive/files.py", line 285, in Upload
self._FilesInsert(param=param)
 File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/pydrive/auth.py", line 75, in _decorated
return decoratee(self, *args, **kwargs)
 File "/home/PycharmProjects/misc/.venv/lib/python3.5/site-packages/pydrive/files.py", line 371, in _FilesInsert
raise ApiRequestError(error)
pydrive.files.ApiRequestError: <HttpError 403 "Project 895099846013 is not found and cannot be used for API calls. If it is recently created, enable Drive API by visiting url If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

这是我的代码 从 pydrive.auth 导入 GoogleAuth 从 pydrive.drive 导入 GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)
file = drive.CreateFile({'title': 'Hello.txt'})
file.SetContentString('Hello World!')
file.Upload()

【问题讨论】:

    标签: python api pydrive


    【解决方案1】:

    这个错误在回溯中有明确的描述:

    403 "项目 895099846013 未找到,不能用于 API 来电。如果是最近创建的,请访问 url 启用 Drive API

    在您的帐户中,您的 Google Drive API 必须处于启用状态。

    你可以在 Console Developer toolbar 看到它

    如果没有看到,请关注instructions

    【讨论】:

      猜你喜欢
      • 2013-11-02
      • 1970-01-01
      • 2014-03-28
      • 2011-11-13
      • 2019-08-06
      • 1970-01-01
      • 2019-11-01
      • 1970-01-01
      • 2021-06-17
      相关资源
      最近更新 更多