0

I am having trouble with the Jawbone API. When I step through the oauth proess using https://github.com/karthikbgl/python-jawbone-up.git I can successfully receive an authorization code and then get a token.

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()

However the token I receive is always the same, and when I use it to call the API, I receive the error :

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

Additionally, if I use the module called access_jawbone with this code:

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

tokenresponse = urllib2.urlopen(url, params)

I get a valid token that I can access the API with.

Does anyone know why the oauth token provided is not working

The below question seems to address the same problem, but I do not understand the answer or how to resolve my problem. Jawbone UP API oAuth and Access Tokens

Community
  • 1
  • 1

1 Answers1

0

I had the same issue. I think that this answer is what is happening: https://stackoverflow.com/a/32984287/1732987

To get around it, I had to log out of all Jawbone stuff in by browser, remove the access token from my new application database, and start the sign in process from a clean slate.

Community
  • 1
  • 1