我如何获得访问令牌? OAuth1与指令参数不兼容

时间:2018-12-07 19:28:52

标签: python evernote

我使用来自官方站点的指令,最后一步,他们说: OAuth1 respons with this parameters oauth_token和oauth_verifier我来自这个instaction in github,github的最后一步得到了error。因此,我尝试使用OAuth1标准版本库执行last step,但我不明白自己在做什么,请,愈,我整天都在寻找Google,并检查该团队的stackoverflow,但是呼吸新鲜空气只能在{{ 3}},其中有人通过AppEngine-OAuth-Library(wtf)以某种方式获得访问令牌。

github-https://discussion.evernote.com/topic/18710-access-token-secret-returning-blank/

官方网站-https://github.com/evernote/evernote-sdk-python

oauth_token = "sudden1306.16789DDB2A2.68747470XXXF2F7777772E666F6F2E636F6D2F.E3319C18235C586BFB93C58A45551293"
oauth_verifier = "62D64740CXXXX9788649BA6E6A0661C7"
consumer_key = 'suddXXX06'
consumer_secret = '9e36013XXXXd195'
request_token_url = 'https://evernote.com/oauth'

oauth = OAuth1Session(client_key=consumer_key, client_secret=consumer_secret,
                      resource_owner_key=oauth_token, resource_owner_secret=None,
                      verifier=oauth_verifier)
# oauth_tokens = requests.get(request_token_url, auth=oauth)
oauth_tokens = oauth.get(request_token_url)
print(oauth_tokens)

然后得到

<Response [404]>

我已经激活了API密钥

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我尝试从此讨论Why am I getting a KeyError when attempting to authenticate with Evernote?中获得一些答案。

我安装了python 2.7和所需的库。并开始获取请求令牌授权网址。我保存了request_token ['oauth_token']和request_token ['oauth_token_secret']。

consumer_key = 'suddXXX306'
consumer_secret = '9e36XX8d195'
request_token_url = 'https://evernote.com/oauth'

client1 = EvernoteClient(
    consumer_key=consumer_key,
    consumer_secret=consumer_secret,
    sandbox=False
)


request_token = client1.get_request_token('http://foo.com')
print client1.get_authorize_url(request_token)

print request_token
print request_token['oauth_token']
print request_token['oauth_token_secret']
exit()

然后我从浏览器中的授权url 中选择了URL,并输入了URL oauth_verifier = ...(保存)example

最后一步,我将所有需要的信息放入此代码中。

oauth_verifier="7D279E750C4CXXXXX7828E173F4"
oauth_token = 'suddeXXX687474703XXXXF6D.5142FBBC6D9CEEE7ADEAD6E65DDD697B'
oauth_token_secret = "2AE25XXXXXACC1D3F65EA887"

consumer_key = 'suddXXXX6'
consumer_secret = '9e3XXXXXX195'

client = EvernoteClient(
    consumer_key=consumer_key,
    consumer_secret=consumer_secret,
    sandbox=False
)

access_token = client.get_access_token(
    oauth_token,
    oauth_token_secret,
    oauth_verifier
)

print access_token
exit()

并获得了 access_token 。如果只需要用于生产Evernote API的令牌,这是最​​简单的方法。