为什么Pocket API总是返回401?

时间:2018-05-02 08:52:36

标签: python

我正在尝试以下代码:

import requests
auth_params = {'consumer_key': '77081-4664470ecdeaa9c127925c30', 'redirect_uri': 'https://weibo.com/u/5069317986/home?topnav=1&wvr=6'}
tkn = requests.post('https://getpocket.com/v3/oauth/request', data = auth_params)
tkn.content

usr_params = {'consumer_key': '77081-4664470ecdeaa9c127925c30', 'code': '21ff0ee0-2b65-fe35-f4b3-a18ed3'}
usr = requests.post('https://getpocket.com/v3/oauth/authorize', data = usr_params)
usr.content

然后:

yes_params = {'consumer_key': '77081-4664470ecdeaa9c127925c30', 'access_token': 'f12deb4e-8ead-9f98-430c-baaee7&username=jelly.wxt%40gmail.com', 'tag':'y'}
yes_result = requests.post('https://getpocket.com/v3/get', data = yes_params)
yes_result.text

但它返回401.How我能解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

HTTP 401状态通常意味着身份验证失败。

查看examples in pocket api documentation,您似乎不应在访问令牌中包含&username=jelly.wxt%40gmail.com

yes_params = {
  'consumer_key': '77081-4664470ecdeaa9c127925c30', 
  'access_token': 'f12deb4e-8ead-9f98-430c-baaee7', 
  'tag':'y'
}
yes_result = requests.post('https://getpocket.com/v3/get', data = yes_params)
yes_result.text