我正在尝试登录figo's API
但是当我尝试将authentication_code交换为authentication_token并最终能够使用API时,我收到以下错误:
File "C:\Python27\lib\site-packages\figo\figo.py", line 69, in connect
raise ssl.SSLError("Certificate validation failed")
ssl.SSLError: ('Certificate validation failed',)
我是从我的本地机器运行的,这是我目前的代码:
import webbrowser
from figo import FigoConnection, FigoSession
client_id = 'CaESKmC8MAhNpDe5rvmWnSkRE_7pkkVIIgMwclgzGcQY'
client_secret = 'STdzfv0GXtEj_bwYn7AgCVszN1kKq5BdgEIKOM_fzybQ'
redirect_url = 'http://localhost:3000'
state = 'qweqwe'
connection = FigoConnection(client_id, client_secret, "http://localhost:3000")
def start_login():
# open the webbrowser to kick of the login process
webbrowser.open(connection.login_url(scope="accounts=ro transactions=ro", state=state))
def process_redirect(authentication_code, state):
# handle the redirect url invocation, which gets passed an authentication code and the state (from the initial login_url call)
# authenticate the call
if state != "qweqwe":
raise Exception("Bogus redirect, wrong state")
# trade in authentication code for access token
token_dict = connection.convert_authentication_code(authentication_code)
# start session
session = FigoSession(token_dict["access_token"])
# access data
for account in session.accounts:
print account.name
设置功能后我遵循的步骤是:
start_login()
这会将我重定向到我的webbrowser,要求我的登录凭据以及将该配置文件中的测试帐户链接到API的另一个确认。 当我登录时,我会再次被重定向到我的重定向URL 并在我的浏览器中显示以下网址:
http://localhost:3000/?state=qweqwe&code=OVzBFGDQD6pyHjs9BAJZCzdYku9exPZoN5uBVbxfpHVjJ9JYQmQmEKxyVKSJK0PSV2xYCNvT7AyZHa3b36Whn3DXMV-mJfHoMJWMHgk7Yi4M
在这个url中我需要为auth_token交换代码,所以我手动从webbrowser复制它并执行以下操作:
authentication_token = 'OVzBFGDQD6pyHjs9BAJZCzdYku9exPZoN5uBVbxfpHVjJ9JYQmQmEKxyVKSJK0PSV2xYCNvT7AyZHa3b36Whn3DXMV-mJfHoMJWMHgk7Yi4M'
process_redirect(authentication_code, state)
那是我收到错误的时候。 我想这个问题出现在connection() function of the API.
中但我无法弄清楚这个函数如何确定我的ssl不正确。