google Drive api v3 file upload errors

女生的网名这么多〃 提交于 2020-12-13 03:45:54

问题


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

I am getting the following errors,

 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.

My pips are as follows,

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

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.


回答1:


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)


来源:https://stackoverflow.com/questions/64603485/google-drive-api-v3-file-upload-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!