Export Google Fit Daily Steps, Weight and Distance to a Google Sheet

Updated on Friday, April 28, 2023

Comments Page 16

Return to post.



That was the problem.

I completely forgot about that.

Thank you very much,


Robert Ellison

Asier - it's failed to get an object for the sheet, so my guess is you didn't rename the tab to 'Metrics' - can you check this?


I'm getting this error:

TypeError: Cannot call method "appendRow" of null.

Any ideas?

Mark Perrin

This is great! Thanks to all who contributed.

I've been looking for the resting heart rate data point and haven't figured it out. Anyone willing to share that?



Agnes Krawczyk

Well. I mostly sorted it out. Turns out I hadn't enabled the Google fitness API. This is my first time working with APIs, and it's all so strange and magical. I've been able to pull today's data plus 80 days. 800 was too much for the software, so I'll figure out some way to programmatically import in chunks.

Thanks again!

Agnes Krawczyk

Hello Robert, thank you for putting this together. I was preparing to transcribe 4 years' worth of weight data by hand and now I won't have to, once I tweak the code to import 1500 records or so.

Unfortunately, I am getting the exact same 403 error as Matthias. I hope it resolves overnight for me as well.

I keep thinking that my problem is with my API not being enabled. I'm not sure how to determine whether or not it is. When I click "Enable APIs and Services", I get a list of out-of-box APIs, with mine nowhere to be found. So if that is the problem, I am at a loss for how to correct it.

For now, I will just hope that it will resolve overnight for me, but in case it doesn't, some insight into enabling custom APIs would be awesome. Google's documentation was not helpful, nor was the rest or the internet.

Thanks again!


Darren Wall

All working now, thanks Robert. I'll continue to follow this article to see what others people do with it. Now to "gamify" my step counts and get moving. Enjoying coding doesn't generally encourage exercise.


Aha! I had kept the brackets in there. Works beautifully now! Thanks.

Robert Ellison

Kevin, the redirect URL looks like https://script.google.com/macros/d/{SCRIPTID}/usercallback. You need to replace {SCRIPTID} with the actual ID (select 'Project properties' from the File menu and find the Script ID in the spreadsheet script editor). If the script id is 1234 then the URL is https://script.google.com/macros/d/1234/usercallback


Robert - this is a great guide - thanks for putting this together.

I am stuck on the redirect URL, though. When I enter it in the API console,

it gives me an error:


Request contains an invalid argument.

Tracking Number: c3721854952865243

Send feedback

In the Google sheet, the Fit menu shows up, as does the sidebar. When I click activate on the sidebar, it takes me to a an error page:

Error: redirect_uri_mismatch

Any ideas?



Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

I Thought He Came With You is Robert Ellison's blog.



Average Server Response Time in Azure Metrics