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

Getting 403 error pulling my own intraday data for AZM, works fine for all other intraday data

I'm able to successfully pull in activity intraday data, HR intraday data, etc, but when I modify that code to pull the AZM data, I keep getting this 403 error:

{"errors":[{"errorType":"insufficient_permissions","fieldName":"n/a","message":"API client is not authorized by Fitbit to access the resource requested."}]}

 

I'm using the URL HTTP request format specified here for activity and here for AZM. I am providing my token for configuration, I've tried hardcoding my user ID and just leaving it as the '-' (as shown in the examples in documentation), calling by date and interval, etc. I also have enabled access to the 'activity' scope which AZM falls under. 

 

Anyone have any ideas on what could be causing this?

Best Answer
0 Votes
8 REPLIES 8

Hi @choxner 

 

If you are able to get intraday for activity but not AZM, it's likely you have a typo somewhere.   Would you please provide the endpoint syntax or code that builds the endpoint that you're trying to execute?   I'll provide another set of eyes for you.

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Much appreciated!

 

Code is in R and I am on personal mode.

 

For some reason I was not allowed to post the dates with actual dashes, so I replaced those with (dash).

 

 

base_url = "https://api.fitbit.com/1/user/-/activities/"
date = "2022(dash)12(dash)20"
resource_path = "active-zone-minutes" # or 'steps', 'calories', etc
detail_level = "5min"

intraday_url = paste0(base_url, sprintf("%s/date/%s/1d/%s.json", resource_path, date, detail_level))
date_url = paste0(base_url, sprintf("%s/date/%s/1d.json", resource_path, date))

output = get(intraday_url, token) # sends HTTP request 

 

 

 

Here's the endpoint this would create the following:

 

 

https://api.fitbit.com/1/user/-/activities/active-zone-minutes/date/2022(dash)12(dash)20/1d/1min.json

 

 

 

This works for activities intraday and time series. It works for AZM time series. It does not work for AZM intraday. 

Best Answer
0 Votes

Would you provide the endpoint syntax you used for active zone minutes intraday data along with the HTTP Status code and error message you received?

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Endpoint:

https://api.fitbit.com/1/user/-/activities/active-zone-minutes/date/2022(dash)12(dash)20/1d/1min.json

 

Error:

{"errors":[{"errorType":"insufficient_permissions","fieldName":"n/a","message":"API client is not authorized by Fitbit to access the resource requested."}]}

 

 

Best Answer
0 Votes

Hi @choxner 

 

If you're providing "(dash)" in the endpoint syntax, that is incorrect and is likely causing the error.   You should be sending us is 

 

https://api.fitbit.com/1/user/-/activities/active-zone-minutes/date/2022-12-20/1d/1min.json

 

This is the correct syntax for the Active Zone Minutes intraday endpoint.   If you're still getting the 403 error, double check that the application type in your dev.fitbit.com/apps setting is configured for "personal", and you're generating an access token for the user that owns the application.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

I am using "-" instead of "(dash)". As stated in my previous post, the forum blocked me from including the date with actual dashes.

 

My application is set to personal, and I am able to access intraday data for other categories. My token is created for my own user, which is the owner of the application.

Best Answer
0 Votes

Hi @choxner 

 

I'm going to send you a private message and request some information from you.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @choxner 

 

I believe I found the problem that you discovered and I'm going to report it to engineering to confirm.   I'll let you know what I find out.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes