完成the python google OAuth2 API并成功接收带有代码的redirect_uri。我在返回的URL中复制“code =”之后的所有内容并将其提交给step2.exchange(code)命令,但python显示以下错误:
文件“C:\ Python34 \ lib \ ssl.py”,第810行,在do_handshake中 self._sslobj.do_handshake()ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:600)
我的问题如下:
1。)代码的正确格式是什么?只需在返回的网址中“code =”之后的所有字符?
2。)还有什么可能导致此错误?我按照其他地方的建议安装了certifi 2015.04.28,但这并没有解决问题。
3.)还有其他任何需要修复的建议吗?
代码如下
from oauth2client.client import flow_from_clientsecrets
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
flow = flow_from_clientsecrets('C:\Python34\client_secrets.json',
scope='https://www.googleapis.com/auth/drive',
redirect_uri='https://www.samtec.com)
auth_uri = flow.step1_get_authorize_url()
#open firefox, send auth_uri to the interwebs
driver = webdriver.Firefox()
driver.get(auth_uri)
name=driver.find_element_by_name("Email")
name.send_keys("******")
name.send_keys(Keys.RETURN)
#wait 10 seconds for the page to load before proceeding
#driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
driver.implicitly_wait(10)
passw=driver.find_element_by_name("Passwd")
passw.send_keys("*******")
passw.send_keys(Keys.RETURN)
#wait for page to load, approve access token
driver.implicitly_wait(10)
allow=driver.find_element_by_id("submit_approve_access")
allow.send_keys(Keys.RETURN)
#get the URL returned to the browser, get the returned code
returnedURL=driver.current_url
if "=" in returnedURL:
param, code = returnedURL.split("=",1)
##remove white space
code=code.strip()
##obtain he OAuth2 object/tokens
credentials = flow.step2_exchange(code) ##error occurs on this line
使用python 3.4.3
由于