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

Google apps script for minute-by-minute data stopped working suddenly

I have been using a Google Apps script in a Google Spreadsheet to download minute by minute data. Today I tried to download data for my account and I got "We're sorry, a server error occurred. Please wait a bit and try again" at the top of the spreadsheet. Did something change in the API that might be causing this? It might be something with Google, have no idea how to debug it.


 I have another spreadsheet that doesn't do the intraday stuff that's working fine.

 

This script was based off of things I found online

Here it is https://jsfiddle.net/j72qbe08/

Best Answer
87 REPLIES 87

Oh right, forgot abou tthe scope of the service. Good catch. Adding your comment to the Github repo's readme.

Best Answer

Hello! Could I ask what you mean by "listing inputing them thorugh "Setup"?

Best Answer
0 Votes

For those that were getting the "dataset" error I did the following:

 

- Go to dev.fitbit.com

- Open your App

- Click Edit Applicatioin Settings

- Make sure the OAuth 2.0 Applicatioin Type is Personal

 

I only realized this because when Fitbit emailed me and said Access to the Parner API no longer needed to request access to the partner API.  In the email they were clear that the above OAuth 2.0 must be clicked Personal and I believe the default is Server (at least that was chosen in my case and I believe gave the dataset error).

Best Answer

Hello All,

 

Has anyone been able to get their heart rate data (intraday) into Google Sheets??

 

If so, could you please post the script. It would be greatly appreciated.

 

Thanks!!

Jim

Best Answer
0 Votes

Based on discussion in this forum I added a version of the script to pull heart rate data. Been a while since I tested it but check it out here:https://github.com/simonbromberg/googlefitbit

Best Answer
0 Votes

Has anyone had any success with downloading intraday heart rate data?

 

I have tried a Google Sheets Script editor discused here: github.com/simonbromberg/googlefitbit. I get ReferenceError: "OAuth2" is not defined.

 

I have tried a R Fitbit Scraper program discussed here: blog.corynissen.com/2015/01/r-package-to-download-fitbit-data.html. I have tried different variations but no success.

 

If anyone has been able to get their heart rate data downloaded lately, please let me know (if you could provide the script/code it would be greatly appreciated!!!!).

 

Thanks,

Jim

 

 

Best Answer
0 Votes

sshi

 

When running the Heartrate.gs in Google Script Editor, I get a ReferenceError: "OAuth2" is not defined when running the Authorize/Download Data Fitbit function.

Under the script editor, I get this error message:

error message

Any help would be greatly appreciated!!!

Thanks,
Jim

Best Answer
0 Votes

Possibly missed a step in the instructions.

 

Also, note: those deprecated warnings are unrelated and don't affect the functioning of the algorithm.

Best Answer
0 Votes

Yes you must have missed a step because it works for me.  I have successfully embedded a version of the script into my google sheet and wow, when it run it I can only run it for a single day as I get per 5-20 second (depending how often it reads) thousands per 24 hrs.  So below, as you can see this is right as I awoke and jumped up out of bed yesterday and my HR jumps from 50s sleeping up to 100+ awake.   I export it to comma separated so I can easily graph in Excel: 

 

2/21/2016 6:33:00,54
2/21/2016 6:33:05,57
2/21/2016 6:33:20,57
2/21/2016 6:33:25,58
2/21/2016 6:33:30,59
2/21/2016 6:33:35,60
2/21/2016 6:33:45,61
2/21/2016 6:33:55,62
2/21/2016 6:34:00,65
2/21/2016 6:34:05,68
2/21/2016 6:34:10,70
2/21/2016 6:34:15,68
2/21/2016 6:34:20,71
2/21/2016 6:34:25,72
2/21/2016 6:34:35,75
2/21/2016 6:34:50,76
2/21/2016 6:35:05,90
2/21/2016 6:35:10,89
2/21/2016 6:35:15,91
2/21/2016 6:35:20,103
2/21/2016 6:35:25,104
2/21/2016 6:35:30,105

 

So, this definitely is a PITA but does work if set up properly.

 

Collin

Best Answer

Took it one step further finally got it exported to Excel and graphed properly!  Totally going to re-dev this entire darn process start to finish into a single executable Powershell app as this PITA is absurd and folks shouldn't have to go through all this to get their HR data.  Since I already wrote an oath2 framework for Twitter (#pstwitter) in Powershell - this shouldn't be too bad.  Will update back here when I get to it!

 

https://twitter.com/collinchaffin/status/701819739094573058

 

24 hr HR graph test

Best Answer

So does any dev know whether Fitbit is simply not allowing grant type of client_credentials for the oAuth2 call to get the access token?

 

I'm getting the much longer access token successfully with 3600 expire returned, but when used in subsequent calls for data throws the 400 bad request error.

Best Answer
0 Votes

I have gotten it to work now, I missed the step to add the Google Auth2 piece.

 

Works perfectly!!

 

Thanks sshi.

Best Answer
0 Votes

It's working with a 30 day token no less!  I have it down to a single param - what day you want and it exports every second of HR data to file.  Updating to try to automate directly to Excel with charts.  Stay tuned!

 

https://twitter.com/collinchaffin/status/703502752106881025

 

Best Answer
0 Votes

I'm at about 90%.  Just polishing and will then add more to framework as I did with my PSTwitter framework.  So, in my testing I can loop through day after day and pull each day with a single command to get all of this in a full xls Excel file.  It even automatically creates the chart as shown!

 

https://twitter.com/collinchaffin/status/704538604668899328

SNAG_2-29-2016_23-20-17.png

Best Answer
This type of thing happens on a regular basis with Google. My advice is to stay away from using Google apps.
Best Answer
0 Votes

Having the same problem you had with the OAuth2 error, how exactly did you fix it?

Best Answer
0 Votes

Anyone Else getting this error when you click download data "TypeError: Cannot call method "getContentText" of undefined."

Best Answer
0 Votes

I have not run the spreadsheet code lately but all my separate new Powershell cmdlet oAuth2 code I have written is still working fine and unlike this spreadsheet solution, I pull one authorization per 30 days storing the token.  I've actually been utilizing my personal stored 30 day oauth token for weeks now as I wrap up going from my wireframe code to final code and it all has been working perfectly.

 

My cmdlet should be released soon and I am also working on a full GUI version of it to allow a calendar selection and I think I may even add a full 30 day capability of any contiguous 30 days to loop over each 24hr query, chart that day, then move on until you would have a directory containing 30 individual xlsx daily spreadsheets.  Additional visualizations may come in phase 2.  Getting the data is super fast but generating the xls chart is darn slow and that's 100% simply waiting for excel to generate it.  Given how many lines of per second data it is charting it does not surprise me, but it slows it down enough that I still may go back in Phase 2 and add some collection-only options.

 

 

Best Answer
0 Votes

I am pleased to announce that my Windows Powershell based module is now available that retrieves daily per-second heartrate data and automatically produces a fully formatted daily Excel report with additional minimum/maximum/average and detailed chart visualization!

 

Read more here and I welcome your feedback and support and please remember to follow me on Twitter for updates!

 

https://twitter.com/collinchaffin/status/709090629599436800

 

Best Answer
@CollinChaffin - Thank you so much! This is great, so much easier than the
google docs method. Great way for me to spend a lazy rainy sunday
morning. Can't wait to continue using this as you develop! Great addition
to the community.
Best Answer
0 Votes