本文介绍了谷歌驱动器API v3文件上传错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python上的google drive api显示以下错误.我的文件上传代码已在 Google Drive api v3文件上传中提及通过python错误

The google drive api on python is showing the following error. My file upload code is already mentioned on 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.一些旧帖子说它需要降级某些软件包.但我希望这将是其他一些问题.

I am using python 3.8.6 . Some old posts say it need to downgrade some packages. But I hope this will be some other issues.

推荐答案

此问题也已通过修改以下连接代码google drive api得到解决.

This issue has been solved by modifying the following connection code too 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)

这篇关于谷歌驱动器API v3文件上传错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 08:38