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

Did it but can't finish as I must go out now. I got BEYOND Authorize!!! I used the OAuth 2. ID as the Consumer Key!

 

Will post later when I complete! I'm SOOOOOO HAPPY!

 

THANK YOU, THANK YOU......THANK YOU!!!

Best Answer
0 Votes

Yea, you have to copy the entire contents of the file interday.gs into a blank script editor. It might look similar to the original one, but it is significantly different. That's the whole point.

 

Sounds like you're on the right track now, you just need to put the right keys into the Set up window now, including the project key. No need to share the sheet anymore.

Best Answer
0 Votes

I see my problem now. I revoked access to the app on my fitbit setting so that I could start all over again. I obviously shouldn't have done this. Now I don't know which application it was and how to get it back. Any suggestions?

 

I'm sooooo close!

Best Answer
0 Votes

Here is what is written in the red warning banner: Access not granted or expired. (line 306, file ""). I hope you can understand this more than I can!

Best Answer
0 Votes

Me again....I've tried restarting my computer, logging out of fitbit and trying to authorize the apps script application but am still met with:

 

Fitbit

The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.

Developer information: invalid_request - Invalid redirect_uri parameter value

 

It would be greatly appreciated if I could find out how to reinstate the fitbit application I revoked this morning in my attempt to start all over again with a clean slate.

 

You have to give me 'A' for effort as I'm still at it, several days now!

Best Answer
0 Votes

As it says, your redirect url is wrong. Either you put it incorrectly into the Fitbit app settings, didn't put one at all, or the project key is incorrect. If you make a new spreadsheet, there's a new project key, and you have to update the redirect url

 

the thing that goes  (but you replace "PROJECT KEY")

https://script.google.com/macros/d/{PROJECT KEY}/usercallback 

 

Best Answer
0 Votes

I've done it correctly.

 

This is my Project Key

Project key
MckphAP-zRbzcw1M7KjOhTKAZcoUUyC-k

 

And this is what I added to the Callback URL:

 

https://script.google.com/macros/d/{MckphAP-zRbzcw1M7KjOhTKAZcoUUyC-k}/usercallback

 

Should I start all over again to try a new one?

Best Answer
0 Votes

 cf my instructions: 

"(Make sure to replace {PROJECT_KEY} with the project key you got from step 3)."

 

You aren't supposed to include the {} braces

 

Best Answer
0 Votes

YEAH!!!!!!!! Thank you so much for your patience! I told you I wasn't a techie! I'm just a senior trying to make my fitbit work for me!!

 

Thanks again! What do I know about brackets? Obviously NOTHING!! hahahaha!

 

Best Answer
0 Votes

Thank you very much, got it working even it's a bit "confusing" my data and formulas  because of its "upside down" nature. For me it would be easier a sort of "append the last day" format.

I suppose it's something around lines 226->347, but I am so noob 😄

 

I'll work around it, I hope 😄

Thank you again 😄

 

Best Answer
0 Votes

Simon, thank you for this script!

 

I was able to download my intraday step data. Woo hoo!

 

Are you planning on adding the intraday heart rate data to the script? That would make the script even more wonderful.

 

Thank again,

Gina

Best Answer
0 Votes

Wasn't planning on it, but it wouldn't be very complicated.

Information on the API for that here:

https://wiki.fitbit.com/display/API/API-Get-Intraday-Time-Series

Best Answer
I solved -it seems- with a new sheet and the SORT function. (just to help anyone in the same corner).

Again, thank you 🙂
Best Answer
0 Votes

@sshi- Even if you we're planning on it, any chance you want to help out your fellow fitbit community members with less technical accumen?  Your script works wonderfully with intraday steps data and I know a lot of us would appreciate it.  I've tried for hours to modify your script to get intraday heartrate data to work but keep ending up with the dreaded "dataset" from "undefined" error.      

Best Answer

Has anyone been successful in getting heart data with this? Everything I've tried just returns an error "TypeError: Cannot call method "getContentText" of undefined."

I have changed the "activities" variable to "activities/heart" and "activities/log/heart," and tried similar combos for the "intradays" variable. I have also changed URLFetchApp to be specific dates instead of including variables, used the exact same URL in the example from the page sshi linked, used date and time ranges where I had initiated a workout (so I know second by second data was being sent to my profile), etc.

Wouldn't that error suggest the script is pulling zero data from my profile?

Best Answer

I have also tried similar things without success. It seems that although it's in the documentation, they still may not have made these endpoints accessible thorugh the API.

Best Answer

@JeremiahFitbit Hey Jeremiah - Any thoughts on the problem we are having?  Have partner level api access, using Oauth 2, and can pull intraday step data but calling for intraday heartrate data isn't returning anything.  We've all tried using the function calls shown on the get-intraday-time-series endpoint documentation page - works for the intraday step data but striking out on the intraday heart rate data.

Best Answer

@mattolomew: I can only say that the Fitbit API is working properly. I'm not an expert in Google Sheets. You'll have to ask its creator.

Best Answer
0 Votes

@mattolomew I coulnd't find API for the resting heart rate from fitbit API docs. I am looking for something to give me just one value per day, such as "activities/log/floors" or "sleep/minutesAsleep". What is the command for that? I assume something like "activities/log/heart"? That didn't work though. Thanks for your help.

 

Abbas 

Best Answer
0 Votes

Thank you to everyone--especially @sshi--for trying to work this out. I don't have the skills to create a script myself, and I appreciate all the efforts to get this to work.

 

That said, the detailed heart rate data should be provided by FitBit as a one-click download for device users. The HR data was the primary reason I bought my Charge HR two weeks ago, and, since I can't download the data, I am returning the device to Amazon.

 

Thanks again!

Gina

Best Answer