pydrive: why has this vertification error suddenly appeared?

你说的曾经没有我的故事 提交于 2021-01-28 11:40:47

问题


I have a python script that downloads files from Google Drive using pydrive. This is the relevent bit of code:

def get_drive_object():
        gauth = GoogleAuth()
        gauth.LoadCredentialsFile("mycreds.txt")
        if gauth.credentials is None:
                # Authenticate if they're not there
                gauth.LocalWebserverAuth()
        elif gauth.access_token_expired:
                # Refresh them if expired
                gauth.Refresh()
        else:
                # Initialize the saved creds
                gauth.Authorize()
        # Save the current credentials to a file
        gauth.SaveCredentialsFile("mycreds.txt")
        # from http://stackoverflow.com/a/24542604/170243
        gauth.LocalWebserverAuth()
        return GoogleDrive(gauth)

Last week it suddenly stopped working, and gives an error of:

quitman$python update.py 
Traceback (most recent call last):
  File "update.py", line 264, in <module>
    chapters = create_chapter_set(get_file_list(), home)
  File "update.py", line 131, in get_file_list
    drive = get_drive_object()
  File "update.py", line 105, in get_drive_object
    gauth.Authorize()
  File "/home/toomanycooks/env/PyDrive-1.0.1-py2.7.egg/pydrive/auth.py", line 422, in Authorize
    self.service = build('drive', 'v2', http=self.http)
  File "/home/toomanycooks/env/oauth2client-1.4.9-py2.7.egg/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/toomanycooks/env/google_api_python_client-1.4.0-py2.7.egg/googleapiclient/discovery.py", line 196, in build
    resp, content = http.request(requested_url)
  File "/home/toomanycooks/env/oauth2client-1.4.9-py2.7.egg/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/toomanycooks/env/oauth2client-1.4.9-py2.7.egg/oauth2client/client.py", line 563, in new_request
    redirections, connection_type)
  File "/home/toomanycooks/env/httplib2-0.9.1-py2.7.egg/httplib2/__init__.py", line 1608, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/toomanycooks/env/httplib2-0.9.1-py2.7.egg/httplib2/__init__.py", line 1350, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/toomanycooks/env/httplib2-0.9.1-py2.7.egg/httplib2/__init__.py", line 1272, in _conn_request
    conn.connect()
  File "/home/toomanycooks/env/httplib2-0.9.1-py2.7.egg/httplib2/__init__.py", line 1059, in connect
    raise SSLHandshakeError(e)
httplib2.SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)
quitman$vim update.py 

I'm completely confused. I've tried generating a new mycreds.txt file, but I'm mystified as to how this error suddently appeared on code that had literally been running for years as a cron job...

EDIT: if I download the whole folder from server (dreamhost) to my local machine, the code runs fine... :s

来源:https://stackoverflow.com/questions/56646706/pydrive-why-has-this-vertification-error-suddenly-appeared

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