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

Intraday Heart Rate Time Series Writeup

I wrote up my experience getting intraday time series heart rate data from the Fitbit API.

 

https://tomhummel.com/2016/03/19/fitbit-heart-rate/

 

Sorry if this is not the right venue for this. 

Best Answer
0 Votes
31 REPLIES 31

Thanks Tom

 

I did use the -n.  I went ahead and just put it all into the script now and posted it into Github.  I create the ssl key on the fly now.  I can create variables for the keys as well, which I'll do later.  

 

If you put your bits/keys in that script and it works, then it's an environmental issue on my mac, OR my Fitbit app and it's keys are not valid.

 

I can make a video of my attempt as well. Showingin more detail in my steps.  Let me know.

Best Answer
0 Votes
Your script on github looks correct to me. If you get a new code in your browser then put that code in your script and run within 10 minutes I expect this to work. What response do you get when you do that?
Best Answer
0 Votes

From the verbose output of the curl command, this is the error within the output.

 

< HTTP/1.1 400 Bad Request

HTTP/1.1 400 Bad Request

 

 

This is the error I get at the end of the command.

 

{"errors":[{"errorType":"invalid_request","message":"Missing 'grant_type' parameter value. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

 

Best Answer
0 Votes
We solved this one already. You have two question marks in your url. Or you have misspelled or omitted the "grant_type" parameter
Best Answer
0 Votes

I'm running the code on github.  It is setup with one ? only, as you instructed.

 

If you pull down that script and run it with your bits, it's all good for you?

Best Answer
0 Votes

I went ahead and created a new Fitbit app, to see if the app, ID or secret were corrupt or something.  I set the app to oAuth2.0-personal.  Created my temp token via the browser using a local Callback URL that I read would work. http://127.0.0.1:8080.  It worked and generated my temp token.

 

I created the personal 64bit key out of the new ID and secret and hard coded it into the curl command.  Updated the callback URL in the curl command.

 

Got the same **ahem** error.  

Best Answer
0 Votes

I made a couple of changes. Hopefully this fixes your problem. https://github.com/roshepard/fitbit/pull/1

Best Answer

THAT WORKED!  I just finished stepping through the full process and confirmed the new method works with the refresh token step.  ALL GOOD!!!  

 

I'll be putting this into a complete script now, THANKS TOTALLY TO YOU TOM, and will post it when it's working. The goal is to have a single script that will be able to loop through on a cron basis and pull the data down.  I'll be playing for the rest of the morning now.

 

YOU ROCK TOM!

Best Answer
0 Votes

Yay! Glad to hear it. I'm debating whether I need to update my post. The `curl` commands work as listed when they aren't embedded in a shell script. 

Best Answer
0 Votes
I'm working on a set of scripts that I'll post when completed, if you want them. For me, I want to be able to loop through all my history and pull down all my stats, and then pull everything thing down daily without manual involvement.

Your guidance was the first step in that process. One question. Where are the additional "scopes" used in the generation of the first token, via the browser? I tried a few others with no luck.
Best Answer
0 Votes

I'd look here re: scopes. https://dev.fitbit.com/docs/oauth2/#scope

Best Answer
0 Votes
Thanks Tom. I was just about to post that I had found them.

Play time.
Best Answer
0 Votes