08-13-2015 11:49
08-13-2015 11:49
I'm using OAuth2.0. I'm able to authenticate and get a valid access token. I then try to do a http GET to https://api.fitbit.com/1/user/-/profile.json setting the "Bearer" header to the access token. That gives me an error "No user found with provided encoded id: -".
So my next attempt is to specifically paste in my user name and do an http GET to https://api.fitbit.com/1/user/myemailalias%40myserver.com/profile.json, again setting the "Bearer" header to the access token. Now I get an error "The API you are requesting could not be found".
Any ideas? Is this an authentication/authorization issue, or am I incorrectly trying to call the GET API?
Answered! Go to the Best Answer.
08-13-2015 12:36
08-13-2015 12:36
Thank you, that was the problem. I added a "Bearer" header, instead of adding an "Authorization" header with a value of "Bearer <access token>". Once I fixed the header I can now use "-" for the user id as expected.
Best Answer08-13-2015 12:22 - edited 08-13-2015 12:23
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
08-13-2015 12:22 - edited 08-13-2015 12:23
The user id expected is your Fitbit user id, not your email address. It looks something like 26FWFL.
You should be able to use '-'. Sounds like you might not be passing the Authorization: Bearer header properly. Here is an example of it working:
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NDA4MzI0NjAsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiIyNkZXRkwiLCJhdWQiOiIyMjhZWDYiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0Mzk0OTIxNDJ9.jkFZ9IbM5iesoVPledsjVTb7bm57Tt48ObNdBlN33Gt" "https://api.fitbit.com/1/user/-/profile.json" -v
> GET /1/user/-/profile.json HTTP/1.1
> User-Agent: curl/7.37.1
> Host: api.fitbit.com
> Accept: */*
> Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NDA4MzI0NjAsInNjb3BlcyI6Indwcm8gd2xvYyB3bnV0IHdzbGUgd3NldCB3aHIgd3dlaSB3YWN0IHdzb2MiLCJzdWIiOiIyNkZXRkwiLCJhdWQiOiIyMjhZWDYiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0Mzk0OTIxNDJ9.erFZ3IbM5iesoVPledsjVTb7bmO3Tt48ObNdBlN22Tg
>
< HTTP/1.1 200 OK
< Server: nginx
< X-UA-Compatible: IE=edge,chrome=1
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-control: no-cache, must-revalidate
< Pragma: no-cache
< Fitbit-Rate-Limit-Limit: 150
< Fitbit-Rate-Limit-Remaining: 149
< Fitbit-Rate-Limit-Reset: 231
< Set-Cookie: JSESSIONID=E61BA5E7700F07BC82CABE14096DA299.fitbit1; Path=/; HttpOnly
< Content-Type: application/json;charset=UTF-8
< Content-Language: en
< Content-Length: 6063
< Vary: Accept-Encoding
< Date: Thu, 13 Aug 2015 18:56:08 GMT
< X-Frame-Options: SAMEORIGIN
<
{"user":{"aboutMe":"Just my work account for testing things. Nothing to see here. You want: https://www.fitbit.com/user/23RJ9B","age":31,"avatar":"https://d6y8zfzc2qfsl.cloudfront.net/28C25557-EBE8-7F8B-5674-097D30FF4629_profile_100_square.png","avatar150":"https://d6y8zfzc2qfsl.cloudfront.net/28C25557-EBE8-7F8B-5674-097D30FF4629_profile_150_square.png","averageDailySteps":1777,"city":"San Francisco","country":"US","dateOfBirth":"1984-01-01","displayName":"Jeremiah","distanceUnit":"METRIC","encodedId":"26FWFL","foodsLocale":"en_US","fullName":"Jeremiah at Work","gender":"MALE","glucoseUnit":"en_US","height":183,"heightUnit":"METRIC","locale":"en_US","memberSince":"2013-06-11","nickname":"Jeremiah @ Work","offsetFromUTCMillis":-25200000,"startDayOfWeek":"SUNDAY","state":"CA","strideLengthRunning":95.2,"strideLengthWalking":75.9,"timezone":"America/Los_Angeles","topBadges":[{"badgeGradientEndColor":"A489E8","badgeGradientStartColor":"38216E","badgeType":"DAILY_STEPS","category":"Daily Steps","cheers":[],"dateTime":"2014-04-19","description":"20,000 steps in a day","earnedMessage":"Congrats on earning your first High Tops badge!","encodedId":"228TPP","image100px":"http://static0.fitbit.com/images/badges_new/100px/badge_daily_steps20k.png","image125px":"http://static0.fitbit.com/images/badges_new/125px/badge_daily_steps20k.png","image300px":"http://static0.fitbit.com/images/badges_new/300px/badge_daily_steps20k.png","image50px":"http://static0.fitbit.com/images/badges_new/badge_daily_steps20k.png","image75px":"http://static0.fitbit.com/images/badges_new/75px/badge_daily_steps20k.png","marketingDescription":"You've walked 20,000 steps And earned the High Tops badge!","mobileDescription":"When it comes to steps, it looks like you're not playing around. This achievement was a slam dunk.","name":"High Tops (20,000 steps in a day)","shareImage640px":"http://static0.fitbit.com/images/badges_new/386px/shareLocalized/en_US/badge_daily_steps20k.png","shareText":"I took 20,000 steps and earned the High Tops badge! #Fitbit","shortDescription":"20,000 steps","shortName":"High Tops","timesAchieved":3,"value":20000},{"badgeGradientEndColor":"FFDB01","badgeGradientStartColor":"D99123","badgeType":"LIFETIME_DISTANCE","category":"Lifetime Distance","cheers":[],"dateTime":"2014-11-09","description":"1,593 lifetime kilometers","earnedMessage":"Whoa! You've earned the New Zealand badge!","encodedId":"22B8LZ","image100px":"http://static0.fitbit.com/images/badges_new/100px/badge_lifetime_miles990.png","image125px":"http://static0.fitbit.com/images/badges_new/125px/badge_lifetime_miles990.png","image300px":"http://static0.fitbit.com/images/badges_new/300px/badge_lifetime_miles990.png","image50px":"http://static0.fitbit.com/images/badges_new/badge_lifetime_miles990.png","image75px":"http://static0.fitbit.com/images/badges_new/75px/badge_lifetime_miles990.png","marketingDescription":"By reaching 1,593 lifetime kilometers, you've earned the New Zealand badge!","mobileDescription":"You've walked the entire length of New Zealand.","name":"New Zealand (1,593 lifetime kilometers)","shareImage640px":"http://static0.fitbit.com/images/badges_new/386px/shareLocalized/en_US/badge_lifetime_miles990_km.png","shareText":"I covered 1,593 kilometers with my #Fitbit and earned the New Zealand badge.","shortDescription":"1,593 kilometers","shortName":"New Zealand","timesAchieved":1,"unit":"KILOMETERS","value":1593},{"badgeGradientEndColor":"38D7FF","badgeGradientStartColor":"2DB4D7","badgeType":"DAILY_FLOORS","category":"Daily Climb","cheers":[],"dateTime":"2015-01-31","description":"200 floors in a day","earnedMessage":"Congrats on earning your first Castle badge!","encodedId":"228TC9","image100px":"http://static0.fitbit.com/images/badges_new/100px/badge_daily_floors200.png","image125px":"http://static0.fitbit.com/images/badges_new/125px/badge_daily_floors200.png","image300px":"http://static0.fitbit.com/images/badges_new/300px/badge_daily_floors200.png","image50px":"http://static0.fitbit.com/images/badges_new/badge_daily_floors200.png","image75px":"http://static0.* Connection #0 to host api.fitbit.com left intact
fitbit.com/images/badges_new/75px/badge_daily_floors200.png","marketingDescription":"You've climbed 200 floors to earn the Castle badge!","mobileDescription":"With this kind of stronghold on the stairs, we proclaim you to be a knight in shining steppage!","name":"Castle (200 floors in a day)","shareImage640px":"http://static0.fitbit.com/images/badges_new/386px/shareLocalized/en_US/badge_daily_floors200.png","shareText":"I climbed 200 flights of stairs and earned the Castle badge! #Fitbit","shortDescription":"200 floors","shortName":"Castle","timesAchieved":1,"value":200},{"badgeGradientEndColor":"00D3D6","badgeGradientStartColor":"007273","badgeType":"LIFETIME_FLOORS","category":"Lifetime Climb","cheers":[],"dateTime":"2015-04-29","description":"2,000 lifetime floors","earnedMessage":"Yipee! You've earned the Hot Air Balloon badge!","encodedId":"228T9T","image100px":"http://static0.fitbit.com/images/badges_new/100px/badge_lifetime_floors2k.png","image125px":"http://static0.fitbit.com/images/badges_new/125px/badge_lifetime_floors2k.png","image300px":"http://static0.fitbit.com/images/badges_new/300px/badge_lifetime_floors2k.png","image50px":"http://static0.fitbit.com/images/badges_new/badge_lifetime_floors2k.png","image75px":"http://static0.fitbit.com/images/badges_new/75px/badge_lifetime_floors2k.png","marketingDescription":"By climbing 2000 lifetime floors, you've earned the Hot Air Balloon badge!","mobileDescription":"That's as high as a hot air balloon! You are really blowing up the lifetime badges list.","name":"Hot Air Balloon (2,000 lifetime floors)","shareImage640px":"http://static0.fitbit.com/images/badges_new/386px/shareLocalized/en_US/badge_lifetime_floors2k.png","shareText":"I climbed 2,000 floors with my #Fitbit and earned the Hot Air Balloon badge.","shortDescription":"2,000 floors","shortName":"Hot Air Balloon","timesAchieved":1,"value":2000}],"waterUnit":"METRIC","waterUnitName":"ml","weight":147,"weightUnit":"METRIC"}}
Best Answer08-13-2015 12:36
08-13-2015 12:36
Thank you, that was the problem. I added a "Bearer" header, instead of adding an "Authorization" header with a value of "Bearer <access token>". Once I fixed the header I can now use "-" for the user id as expected.
Best Answer