02-03-2020
06:48
- last edited on
02-07-2020
11:53
by
JohnFitbit
02-03-2020
06:48
- last edited on
02-07-2020
11:53
by
JohnFitbit
Error Detail -
{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access profile data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}
My .Net Code API to get -
var date = DateTime.Now;
string str = "afterDate='"+ String.Format("{0:yyyy-MM-dd}", date) + "'&sort=desc&limit=40&offset=0";
var client = new RestClient("https://api.fitbit.com/1/user/-/activities/list.json?" + str);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Basic <Redacted>"); //ClientID:ClientSecret Base64
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", "<Redacted>");
request.AddParameter("redirect_uri", "http://localhost:8100/stats");
request.AddParameter("scope", "weight location settings nutrition social activity heartrate profile sleep");
IRestResponse response = client.Execute(request);
Please help to correct this code.
Answered! Go to the Best Answer.
02-07-2020 12:02
02-07-2020 12:02
Hi @AnilSingh ,
You don't need a license to access the data. You only need a user's consent.
Looking at your post, it looks like you are trying to access your own data, which you can do through any application type as long as you give consent to your application to access your data.
If you haven't already done so, I recommend going through your oAuth 2.0 Tutorial at your application settings page at https://dev.fitbit.com/apps/details/<YourClientID>. The tutorial will guide you through your application's authorization process and you'll have to select which data in the authorization page to allow your application access to.
Once you've authorized your application to access your data, the following steps will show you how to use your access token and begin making API calls to your account.
I hope this helps. Please let me know if you have any additional questions.
02-03-2020
06:33
- last edited on
02-04-2020
15:22
by
JohnFitbit
02-03-2020
06:33
- last edited on
02-04-2020
15:22
by
JohnFitbit
I am Getting error when I am calling an API - https://api.fitbit.com/1/user/87ZF3T/activities/list.json?afterDate='2019-07-17'&sort=desc&limit=40&...
My Code is -
var date = DateTime.Now;
string str = "afterDate='"+ String.Format("{0:yyyy-MM-dd}", date) + "'&sort=desc&limit=40&offset=0";
var client = new RestClient("https://api.fitbit.com/1/user/-/activities/list.json?" + str);
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Basic <Redacted>"); //clientId:secretId
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", "<Redacted>");
request.AddParameter("redirect_uri", "http://localhost:8100/stats");
request.AddParameter("scope", "weight location settings nutrition social activity heartrate profile sleep");
IRestResponse response = client.Execute(request);
Response Error -
{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access profile data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}
02-03-2020 17:25 - edited 02-03-2020 17:26
02-03-2020 17:25 - edited 02-03-2020 17:26
Hi @AnilSingh,
Welcome to the forums!
I believe I have responded to you via email, but I'll be happy to post the answer here as well.
This error typically occurs when the user you are trying to fetch data from has not given your application consent to extract data from a particular scope. In this case, it looks like the user did not give your application consent to access their profile data on the authorization page during the user consent process.
If the user has not given to access certain scopes, you will not be able to make api calls to fetch data from those resources. You'll need to have the user go through the authorization process again to update their preferences (check the profile scope) in order to make API calls to this resource.
I hope this helps. Let me know if you have any questions.
02-04-2020 01:10
02-04-2020 01:10
Hi John,
I also tried for single scope (profile) but I got the same error message.
Please investigate and guide me to resolve this issue.
Do you want my access detail?
Thanks
02-04-2020 15:20
02-04-2020 15:20
@AnilSingh I checked the authorized applications for the user ID you provided and saw that your application was not listed as an authorized application to access the data.
Could you go through the authorization process again and enable all scopes, then try your request again? If the issue persists, please let me know.
02-06-2020 23:19
02-06-2020 23:19
Yes please help me. Till now I'm not able to access the data.
Please explain the steps to resolve this issue. If possible at your end please allow to access data.
Thank you
02-07-2020 00:20
02-07-2020 00:20
Hi JohnFitbit,
Do I need a licence key for access the data in my application?
Thanks,
Anil
02-07-2020 12:02
02-07-2020 12:02
Hi @AnilSingh ,
You don't need a license to access the data. You only need a user's consent.
Looking at your post, it looks like you are trying to access your own data, which you can do through any application type as long as you give consent to your application to access your data.
If you haven't already done so, I recommend going through your oAuth 2.0 Tutorial at your application settings page at https://dev.fitbit.com/apps/details/<YourClientID>. The tutorial will guide you through your application's authorization process and you'll have to select which data in the authorization page to allow your application access to.
Once you've authorized your application to access your data, the following steps will show you how to use your access token and begin making API calls to your account.
I hope this helps. Please let me know if you have any additional questions.
02-10-2020 06:59
02-10-2020 06:59
@JohnFitbit, Thank you very much for your great support. Now, I resolved my issue.
02-10-2020 07:00
02-10-2020 07:00
02-10-2020 16:51
02-10-2020 16:51
@AnilSingh Great! Let me know if you need anything else.
02-12-2020 07:34
02-12-2020 07:34
Hi JohnFitbit,
One more thing, I successfully access your all activities APIs but the activates (speed steps, calories, distance, and so on) value getting 0.
Please take a look and get back to me.
See the response JSON -
Thank You.
02-12-2020 14:46
02-12-2020 14:46
@AnilSingh Can you provide me with the endpoint you used and the response you received? If you attached anything to your last post, I am not able to see it.
02-12-2020 23:46
02-12-2020 23:46
02-13-2020 16:47
02-13-2020 16:47
@AnilSingh There doesn't appear to be anything wrong with the API since you were able to receive data for this activity log.
After looking at the activity itself, it looks like a Walk activity was started from the device, lasted 9 minutes, but detected no activity. Was the device worn during the activity? It might explain why 0s were returned for steps, distance, and calories.
02-14-2020 00:58
02-14-2020 00:58
02-14-2020 11:09
02-14-2020 11:09
Hi @AnilSingh
On 2020-02-11, I think the problem is you recorded the activity on the tracker for too short a period of time. The smallest intraday interval for activity is 1 min. However, you recorded the activity on your tracker for 18 seconds. In the intraday data, we see no data recorded for steps. My recommendation is to enable the exercise, walk or run for a few minutes, stop the exercise recording and sync your tracker. I would expect you to see steps.
Gordon