我正在尝试通过python将数据发送到Google电子表格。很多教程后来,我遇到了以下错误。
当我运行这个Python代码时:
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run_flow
from oauth2client.file import Storage
from oauth2client.tools import argparser
CLIENT_ID = 'xxxxxxxgleusercontent.com'
CLIENT_SECRET = 'xxxxxxxxx'
flow = OAuth2WebServerFlow(
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
scope = 'https://spreadsheets.google.com/feeds https://docs.google.com/feeds',
redirect_uri = 'http://example.com/auth_return'
)
flags = argparser.parse_args(args=[])
storage = Storage('creds.data')
credentials = run_flow(flow, storage, flags)
print "access_token: %s" % credentials.access_token
我明白了(很好)
http://static.indjango.com/python-gspread/screen-8.png(暂不发布照片)
问题:
Traceback (most recent call last):
File "/home/pi/Desktop/gs/gs.py", line 43, in <module>
credentials = run_flow(flow, storage, flags)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 135, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/tools.py", line 235, in run_flow
credential = flow.step2_exchange(code, http=http)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 135, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 2102, in step2_exchange
headers=headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1609, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1351, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1272, in _conn_request
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1059, in connect
raise SSLHandshakeError(e)
SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
我该怎么做才能解决这个问题?
This特别教程。