02-17-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm implementing Fitbit API into an app for the iPhone application and when i make API calls i either get a response that is a bunch of categories or i get errors like "insufficient permissions". Disregarding any specific examples or specific errors i'm simply not getting the data back i expect or seein the Fitbit documentation. I have read the documentation extensively.
For the most part i am familar with OAuth 2.0 and it's implementation as is shown in it's RFC documentation.
Set up:
I authorize the app with a callback URL and the authorization URL https://www.fitbit.com/oauth2/authorize
i then take my Authentication Code and use it to get an Access Token by calling this API
https://api.fitbit.com/oauth2/token
My app is registered and i provide the calls with the correct client_id and client_secret as well as the Scope value set to activity
I take this token and set it as a header in this format "Bearer <access_token>" with the header as Authorization
when i make this call https://api.fitbit.com/1/user/-/activities/tracker/steps.json
i get back an object with a key of "categories" which is an array of objects of activities none of which has the steps.
Taking an example from the documentation using this example
GET https://api.fitbit.com/1/user/[user-id]/activities.json
where the user id is the hyphen value all i get is insuffient scope
Answered! Go to the Best Answer.
Accepted Solutions
02-18-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-18-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Sure, if you go here: https://dev.fitbit.com/docs/help/
The third bullet point under "Let's go far, together!", click on "here" and fill out the form. Keep in mind that it may take some time before your request is reviewed.

02-17-2016 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-17-2016 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu You need to include a date like it shows in the docs. For example, this endpoint should work: https://api.fitbit.com/1/user/-/activities/steps/date/2016-02-09/2016-02-11.json

02-17-2016 13:41 - edited 02-17-2016 13:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 13:41 - edited 02-17-2016 13:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Using this the first API call in the Activity section as an example
GET https://api.fitbitcom/1/user/[user-id]/activities/date/[date].json
i run this in my set up:
https://api.fitbit.com/1/user/-/activities/tracker/steps/date/today.json
which is already seems wrong because when i do
https://api.fitbit.com/1/user/-/activities/date/today.json
i get an insufficient_scope error
so i have to replace the <activities> with <activities/tracker/steps> in order to get anything back and what i get back doesn't match the api i get something like this (this is a small piece of 4500 lines returned)
{ "categories": [ { "activities": [ { "accessLevel": "PUBLIC", "activityLevels": [ { "id": 3016, "maxSpeedMPH": -1, "mets": 8.5, "minSpeedMPH": -1, "name": "6 - 8 inch step" }, { "id": 3017, "maxSpeedMPH": -1, "mets": 10, "minSpeedMPH": -1, "name": "10 - 12 inch step" } ], "hasSpeed": false, "id": 90004, "name": "Aerobic step" }, { "accessLevel": "PUBLIC", "hasSpeed": false, "id": 3015, "mets": 6.5, "name": "Aerobic, general" }] } }
what i expect to get back, as mentioned in the docs is,
{ "activities":[ { "activityId":51007, "activityParentId":90019, "calories":230, "description":"7mph", "distance":2.04, "duration":1097053, "hasStartTime":true, "isFavorite":true, "logId":1154701, "name":"Treadmill, 0% Incline", "startTime":"00:25", "steps":3783 } ], "goals":{ "caloriesOut":2826, "distance":8.05, "floors":150, "steps":10000 }, "summary":{ "activityCalories":230, "caloriesBMR":1913, "caloriesOut":2143, "distances":[ {"activity":"tracker", "distance":1.32}, {"activity":"loggedActivities", "distance":0}, {"activity":"total","distance":1.32}, {"activity":"veryActive", "distance":0.51}, {"activity":"moderatelyActive", "distance":0.51}, {"activity":"lightlyActive", "distance":0.51}, {"activity":"sedentaryActive", "distance":0.51}, {"activity":"Treadmill, 0% Incline", "distance":3.28} ], "elevation":48.77, "fairlyActiveMinutes":0, "floors":16, "lightlyActiveMinutes":0, "marginalCalories":200, "sedentaryMinutes":1166, "steps":0, "veryActiveMinutes":0 } }

02-17-2016 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-17-2016 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Try using a date range like I did above, or if you want today try doing this as a workaround:
https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2016-02-17/2016-02-17.json

02-17-2016 14:30
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 14:30
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I didn't realize that i needed to refresh the screen to see your post so i apologize for the late reply.
When i use the API that you post i get this out put
{ "errors": [ { "errorType": "validation", "fieldName": "resource owner", "message": "Resource owner is required" } ] }
Granted in this example i am using post man, but i will run it on my device and see what it post out.
What's still baffling is why the API call i get directly from the documentation is not working. Am i viewing an outdated documentation? I just go to dev.fitbit.com

02-17-2016 14:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 14:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
when i run your API call on my iPhone device i get a better response
********** ********** ********** ********** ********** https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2016-02-17/2016-02-17.json : [:] : { "activities-tracker-steps" = ( { dateTime = "2016-02-17"; value = 0; } ); } ********** ********** ********** ********** **********

02-17-2016 14:49 - edited 02-17-2016 14:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 14:49 - edited 02-17-2016 14:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The API call i want to make in my application is
https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2016-02-17/1d/1m/time/03:45/05:45.json
which that returns to me the same output with the categories that is 4500 lines long or so.
My Goal: download the data between 2 times (13:30~17:30) for a given day
the documentation URL reference for what i'm doing is this one

02-17-2016 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-17-2016 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Interesting. Try this endpoint, this should get you the data you're looking for:
https://api.fitbit.com/1/user/-/activities/steps/date/2016-02-17/1d/time/03:45/05:45.json
Keep me posted.

02-17-2016 15:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-17-2016 15:32
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I refershed all my tokens to be sure and i ran that call and i get this result
********** ********** ********** ********** ********** https://api.fitbit.com/1/user/-/activities/steps/date/2016-02-17/1d/time/03:45/05:45.json : [:] : { errors = ( { errorType = "insufficient_permissions"; message = "API client is not authorized by Fitbit to access the resource requested. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."; } ); success = 0; } ********** ********** ****(lldb)
when i set the scope for the authorization call i use activity

02-17-2016 15:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-17-2016 15:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Is your app registered as a personal app? And are you trying to access your own data?

02-18-2016 06:31 - edited 02-18-2016 07:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-18-2016 06:31 - edited 02-18-2016 07:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The app is registered under a company Dev-Fitbit account and i'm using my Fitbit account to try to access the data.
I use the Grant Type of Authorization Code
In the app settings the app is registered as a Client app for OAuth 2.0 Application Type

02-18-2016 06:39 - edited 02-18-2016 07:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-18-2016 06:39 - edited 02-18-2016 07:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
What about partner API access? Does my app need to be approved before I can access the information on any logged in account other than the app who has the App registered?
when i run this api call
"https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2016-02-15/2016-02-15.json"
i get this response:
********** ********** ********** ********** ********** https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2016-02-15/2016-02-15.json : [:] : { "activities-tracker-steps" = ( { dateTime = "2016-02-15"; value = 896; } ); } ********** ********** ********** ********** **********
which is correct. So that is good. Now the only thing i need working is the Activity Intraday Time Series API calls.
The logged in user is only going to be getting data for themself and no one else. Does that mean that my app should be set to personal?

02-18-2016 11:41 - edited 02-18-2016 11:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-18-2016 11:41 - edited 02-18-2016 11:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Correct, your app will need to be reviewed and approved for Intraday access in order to make calls for someone other than the owner of the app.
Personal means only the owner has access to Intraday data.
Hope that clears things up.

02-18-2016 11:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-18-2016 11:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Will you please point me in the right direction for getting the APP approved?
I don't see anything on the application details page that allows to request for approval.

02-18-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-18-2016 12:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu Sure, if you go here: https://dev.fitbit.com/docs/help/
The third bullet point under "Let's go far, together!", click on "here" and fill out the form. Keep in mind that it may take some time before your request is reviewed.

02-18-2016 12:18
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-18-2016 12:18
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thanks a bunch, i will apply right away!
02-18-2016 12:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-18-2016 12:57
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Psyaryu No problem, hope to see you around!

10-31-2017 08:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-31-2017 08:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
Have you managed to solve your problem? I'm facing the same issue...

12-18-2017 21:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-18-2017 21:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
Currently we are using following endpoint to get Step data for a particular user.
https://api.fitbit.com/1/user/-/activities/tracker/steps/date/2017-06-06/today.json
It gives day data, but we need interday data for the same duration.
Can you please let us know how can we get it.
Regards,
Sunil Sutrawe

12-19-2017 14:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-19-2017 14:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Intraday access question is answered at this thread:
Thanks

