【问题标题】:Receiving the same invalid Jawbone Api token接收相同的无效 Jawbone Api 令牌
【发布时间】:2016-10-31 08:27:06
【问题描述】:

我在使用 Jawbone API 时遇到问题。当我使用https://github.com/karthikbgl/python-jawbone-up.git 逐步完成oauth 过程时,我可以成功接收授权码,然后获得令牌。

def access_token(self, code, grant_type='authorization_code'):
    '''
    Get the access code for a user with a auth code.
    '''

    params = {
        'code'          : code,
        'client_id'     : self.client_id,
        'client_secret' : self.client_secret,
        'grant_type'    : grant_type
    }

    context = {
        'base_url': self.base_url,
        'params'  : urllib.urlencode(params)
    }

    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json',
        'X-Target-URI': 'https://jawbone.com',
        'host': 'jawbone.com'
    }

    token_url = '{base_url}auth/oauth2/token/?{params}'.format(**context)

    res = requests.get(token_url, headers=headers)
    return res.json()

但是我收到的令牌总是一样的,当我使用它调用 API 时,我收到错误:

{"meta": {"code": 401, "error_detail": "You must be logged in to perform that action", "error_type": "authentication_error", "message": "Unauthorized"}, "data": {}}

另外,如果我在这段代码中使用名为 access_jawbone 的模块:

 params = urllib.urlencode({
                          'email': username,
                          'pwd': password,
                          'service': 'nudge'
                          })

tokenresponse = urllib2.urlopen(url, params)

我获得了一个可以访问 API 的有效令牌。

有谁知道为什么提供的 oauth 令牌不起作用

以下问题似乎解决了同样的问题,但我不明白答案或如何解决我的问题。 Jawbone UP API oAuth and Access Tokens

【问题讨论】:

    标签: python oauth oauth-2.0 access-token jawbone


    【解决方案1】:

    我有同样的问题。我认为这个答案是正在发生的事情: https://stackoverflow.com/a/32984287/1732987

    为了解决这个问题,我必须通过浏览器注销所有 Jawbone 内容,从我的新应用程序数据库中删除访问令牌,然后重新开始登录过程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-05
      • 2021-12-26
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多