我怎样才能获得访问令牌? OAuth1 与指令参数不兼容
How can i get Access Token? OAuth1 incompatible with instruction parameters
我使用官方网站的说明,最后一步他们说:
OAuth1 respons with this parameters oauth_token and oauth_verifier i was get from this instaction in github, last step in github got error. So i try use OAuth1 standart libary to do last step, and i dont understand what i do wrong, please healp, i siting all day for googling and checking Whosebug for this team, but breath of fresh air only find in https://discussion.evernote.com/topic/18710-access-token-secret-returning-blank/ 有人以某种方式使用 AppEngine-OAuth-Library(wtf) 获取访问令牌。
github - https://github.com/evernote/evernote-sdk-python
官方网站 - https://dev.evernote.com/doc/articles/authentication.php
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 密钥
我解决了这个问题。我试着从这个讨论 Why am I getting a KeyError when attempting to authenticate with Evernote? 中回答一些细节。
我安装了 python 2.7 和所需的库。并开始获取 请求令牌 和 授权 url。我保存了 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并进入URLoauth_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。
我使用官方网站的说明,最后一步他们说: OAuth1 respons with this parameters oauth_token and oauth_verifier i was get from this instaction in github, last step in github got error. So i try use OAuth1 standart libary to do last step, and i dont understand what i do wrong, please healp, i siting all day for googling and checking Whosebug for this team, but breath of fresh air only find in https://discussion.evernote.com/topic/18710-access-token-secret-returning-blank/ 有人以某种方式使用 AppEngine-OAuth-Library(wtf) 获取访问令牌。
github - https://github.com/evernote/evernote-sdk-python
官方网站 - https://dev.evernote.com/doc/articles/authentication.php
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 密钥
我解决了这个问题。我试着从这个讨论 Why am I getting a KeyError when attempting to authenticate with Evernote? 中回答一些细节。
我安装了 python 2.7 和所需的库。并开始获取 请求令牌 和 授权 url。我保存了 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并进入URLoauth_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。