Comments
Hi,
thank you for the quick answer.
Yea, i have no distance in it.
I'm only interested to monitor my weight.
What should I do?
Thanks again
Hi Sandy, sorry that didn't work. I can think of two possibilities. The first is that you didn't authorize all the required scopes - seems unlikely but you could revoke access again and then check the consent screen carefully to make sure that all the scopes are granted. The other reason could be that your fit account doesn't have distance in it (that looks like the metric with the error). You could use the API Explorer to see which metrics are available. If I think of anything else I'll post back.
Hello Robert,
so I disconnected the script from google fit.
After on google sheets, from the google fit menu i did "reset settings", re authorized again from the link, authorization ok.
When I do "get metrics" i get the same error.
I really don't know what to do.
Could be that I'm running the script from my browser on my Pc?
Because on the google sheets app from my smartphone i have no menu, i did everything from my pc.
Am I missing something?
On my smartphone tho I installed google sheets app and cloud console.
Thank you for your patience
Robert, Thanks for pointing me in the right direction.
I found the dataTypeName here: https://developers.google.com/fit/datatypes/activity#heart_points
It's com.google.heart_minutes right?
I'll study your script to figure out how dataSourceId is used for the other metrics.
John, heart points would be a great add. I'll look at it the next time I need to update the script. If you want to take a crack at it use the API Explorer linked above to find the dataTypeName and dataSourceId to add to the list of metrics being fetched.
Sandy, it sounds like you don't have Google Fit authorized or it's in a bad state. Follow the instructions in the second to last paragraph of the post to reset and see if that fixes the problem.
Hello Robert,
thank you for your work.
I would like to ask you some help.
I followed your guide, authorization ok on the google sheets from the "Google Fit" menu.
But when i click on "get metrics from yesterday" i get back this error:
"Exception: Request failed for https://www.googleapis.com returned code 403. Truncated server response: { "error": { "code": 403, "message": "datasource not found or not readable: derived:com.google.distance.delta:com.google.android.gms:merg... (use muteHttpExceptions option to examine full response)"
My "Fitness API" is enabled and on the dashboard tells me 8 request with 100% error.
Client ID and Secret are right in the script, i double checked and I tried to copy past them again.
On the "OAuth consent screen" i just set the name "My Fit App"
My "OAuth 2.0 client" name is "Fit1" but I don't think this is related to the problem.
What am I missing?
Could you help me?
Thank you in advance
Hello Robert,
Thank you for taking the time to show us how you can get the script you wrote working.
It works just great for me. I'd love to take things to the next level and record daily heart points. Steps are good but I'd really like to capture heart point data as well and share it with a group of friends.
I hope you can find the time to update your script to capture this data.
Thanks in advance.
Rajat - I think it depends on how many people you want to make this available to. If it's a personal project you're probably OK. If it's a product you're making generally available then you probably need the Google verification. I know they have been locking down apps script more and more.
Hi Robert
Thanks for the message.
I had another query. This .gs script uses the following sensitive scopes:
https://www.googleapis.com/auth/script.container.ui
https://www.googleapis.com/auth/script.external_request
https://www.googleapis.com/auth/spreadsheets
However, the published app, when used by a new user says unverified. I guess, the app has to be verified by google. Is there any workaround to this or this is the only method?
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.