Jawbone APIに問題があります。 https://github.com/karthikbgl/python-jawbone-up.gitを使用してoauth proessを実行すると、認証コードを正常に受信してトークンを取得できます。私はこれでaccess_jawboneと呼ばれるモジュールを使用する場合、さらに同じ無効なJawbone Apiトークンを受信しました
{"meta": {"code": 401, "error_detail": "You must be logged in to perform that action", "error_type": "authentication_error", "message": "Unauthorized"}, "data": {}}
:私が受け取るトークンが常に同じである、と私はAPIを呼び出すためにそれを使用する場合、私はエラーを受け取りしかし
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()
コード:
params = urllib.urlencode({
'email': username,
'pwd': password,
'service': 'nudge'
})
tokenresponse = urllib2.urlopen(url, params)
私はAPIにアクセスできる有効なトークンを取得します。提供のOAuthトークンは、以下の質問は、同じ問題に取り組むように思わ
が機能しない理由
は誰もが知っていますが、私は答えまたはどのように私の問題を解決するには理解していません。 Jawbone UP API oAuth and Access Tokens