The Apigee console has strict requirements around response headers that the Jawbone image endpoints violate, so those endpoints are not available from that console.
There also would not be much value to having those endpoints there as they return raw PNG data.
Instead, here is some sample Python code using the requests_oauthlib module.
First, you need to perform the OAuth handshake to get a token. Step 1 is to go to the UP authorization_url
, login to your UP account, and grant access:
>>> import requests_oauthlib
>>> up = requests_oauthlib.OAuth2Session(client_id=client_id, scope=['sleep_read'], redirect_uri=redirect_uri)
>>> up.authorization_url('https://jawbone.com/auth/oauth2/auth')[0]
u'https://jawbone.com/auth/oauth2/auth?response_type=code&client_id=-bry_vwGDwE&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2Fauth&scope=sleep_read&state=LV2BAPq3dIz6eKu3xz420Zujb5f911
After granting access, the UP API will redirect the user back to your application. Step 2 is to copy that URL you're redirected back to and use it to get a token:
>>> token = up.fetch_token('https://jawbone.com/auth/oauth2/token', authorization_response=REDIRECTED_URL, client_secret=client_secret)
At this point, the OAuth2Session object up
is ready to query the API (you can also use this saved token to create another OAuth2Session object later).
So let's query the sleeps endpoint to get a sleep_xid
.
>>> sleepr = up.get('https://jawbone.com/nudge/api/v.1.1/users/@me/sleeps')
>>> sleep_xid = sleepr.json()['data']['items'][0]['xid']
Now that we have an xid for a particular sleep event, you can get its graph image, which the API returns as raw PNG data:
>>> sleepimgr = up.get('https://jawbone.com/nudge/api/v.1.1/sleeps/{}/image'.format(sleep_xid))
>>> sleepimgr.text
u'\u2030PNG\r\n...