【问题标题】:google Drive api v3 file upload errorsgoogle Drive api v3 文件上传错误
【发布时间】:2020-10-30 06:12:54
【问题描述】:

python 上的 google drive api 显示以下错误。我的文件上传代码在Google Drive api v3 file upload errors via python上已经提到了

我收到以下错误,

 File "/opt/cppython/lib/python3.8/site-packages/httplib2/__init__.py", line 1685, in _request
    raise RedirectMissingLocation(
httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.

我的点数如下,

google-api-core          1.22.4
google-api-python-client 1.12.3
google-auth              1.22.1
google-auth-httplib2     0.0.4
google-auth-oauthlib     0.4.1
googleapis-common-protos 1.52.0
httplib2                 0.18.1

我正在使用 python 3.8.6 。一些旧帖子说它需要降级一些软件包。但我希望这会是其他一些问题。

【问题讨论】:

  • 我可以问你关于你的问题吗?你能提供你当前的脚本来复制Redirected but the response is missing a Location: header.的错误吗?因为当我在your link 中测试你的脚本时,我确认了Bad Request 不是Redirected but the response is missing a Location: header. 的错误。
  • 现在我注意到您已经回答了您的问题。我为此道歉。很高兴您的问题得到解决。

标签: python-3.x google-api google-drive-api google-api-python-client service-accounts


【解决方案1】:

这个问题已经通过google drive api修改如下连接代码解决了。

SCOPES = ['https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.file','https://www.googleapis.com/auth/drive.appdata']
credentials = ServiceAccountCredentials.from_json_keyfile_name('json-file', SCOPES)
http=Http()
http.redirect_codes = http.redirect_codes - {308}
http_auth = credentials.authorize(http)
drive_service = build('drive', 'v3', http=http_auth,cache_discovery=False)

【讨论】:

    猜你喜欢
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多