【问题标题】:Why Pocket API always returns 401?为什么 Pocket API 总是返回 401?
【发布时间】:2018-05-08 19:45:12
【问题描述】:

我正在尝试以下代码:

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。我该如何解决?

【问题讨论】:

    标签: python


    【解决方案1】:

    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
    

    【讨论】:

      猜你喜欢
      • 2017-05-15
      • 2018-04-03
      • 2021-08-12
      • 2020-05-27
      • 2021-01-24
      • 2016-05-22
      • 2016-06-14
      • 2020-08-28
      • 1970-01-01
      相关资源
      最近更新 更多