You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python3 SDK调用Evernote OAuth时遇KeyError: 'oauth_token'问题求助

Evernote OAuth授权获取Access Token报错解决

核心问题:oauth_verifier的正确获取方式

你填的2222是无效值,oauth_verifier不是随便填写的,正确获取流程如下:

  • 拿到request_token后,用其中的oauth_token构造Evernote授权页面URL:
    沙箱环境:https://sandbox.evernote.com/OAuth.action?oauth_token=你的request_token中的oauth_token值
    生产环境:https://www.evernote.com/OAuth.action?oauth_token=你的request_token中的oauth_token值
  • 引导用户在该页面登录并授权你的应用,授权完成后,Evernote会跳转到你调用get_request_token时传入的http://localhost回调地址,同时在URL参数里带上oauth_verifier(比如http://localhost?oauth_verifier=abc123),这个参数值就是你需要的真实oauth_verifier。

解决报错的步骤

  1. 核对回调地址:确保调用get_request_token时传的http://localhost,和你在Evernote开发者后台配置的回调地址完全一致(本地测试可直接填http://localhost)。
  2. 提取真实oauth_verifier:从授权后的回调URL参数中拿到正确的oauth_verifier值,不要用测试值。
  3. 正确调用get_access_token:将真实的oauth_verifier传入方法,示例:
    client.get_access_token(oauth_verifier='从回调URL获取的真实值')
    

报错原因说明

传入无效的oauth_verifier时,Evernote的API不会返回有效的oauth_token字段,导致代码执行到self.token = access_token_dict['oauth_token']时触发KeyError。

内容的提问来源于stack exchange,提问作者dr0ant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 15:33:14