Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can not retrieve Steps. Using the OAuth2 process with C# HttpWebRequest

I am trying to retrieve steps I entered on the site using the new OAuth2 process.  I am able to get my profile but every single call to get my steps come back with an error or a huge json string with general info. 

 

What Am I doing wrong ?

 

Here are the calls and the errors I get:

 

https://api.fitbit.com/1/user/userid/activities/steps/date/2016-02-20/2016-02-25.json

{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access activity data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

https://api.fitbitcom/1/user/userid/activities/date/2016-02-20.json

NameResolutionFailure

https://api.fitbit.com/1/user/userid/activities/tracker/steps/date/2016-02-20/2016-02-25.json

{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access activity data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

https://api.fitbit.com/1/user/-/activities/date/2016-02-23.json

{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access activity data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

https://api.fitbit.com/1/user/-/activities/steps/date/2016-02-23.json

Huge Json string with every single activity description fitbit may have but not related at all with my profile.

Best Answer
0 Votes
1 REPLY 1

Never mind,  I was looking at th wrong place. 

 

It appears the "insufficient_scope" message got to do with the scope you include during the authorization GET string  and not during the resource request (I am using Code Flow ). You do have to include , the resource more than once !!!! in the authorization and while asking for the resource.

 

This one works:

 

authorization:

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=USER_ID&scope=profile activity

 

request resource:

 

https://api.fitbit.com/1/user/-/activities/date/" + String.Format("{0:yyyy-MM-dd}", startdate) + ".json

Best Answer
0 Votes