Comments
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?
Rajat - the problem is that there is no spreadsheet app for a web service and so you can't use it to open a UI. You'll need to handle the OAuth flow using the UI service in the web app. I don't have an example here to share - if I ever do it this way I'll post back with sample code but for now I can't help you further with this.
Hi
I am getting this error while deploying as web app.
Exception: Cannot call SpreadsheetApp.getUi() from this context. (line 154, file "Code")
I have added the below code
// This function successfully handles a GET request with safe and supported return type
function doGet() {
clearProps()
showSidebar()
getHistory()
return ContentService.createTextOutput('I just successfully handled your GET request.');
}
can you help here.
Hi Subham, I just tested the 60 day update and it worked fine for me. Can you try again in case it was a temporary error? If that doesn't help make sure you have the latest code (it's been updated a few times, not sure when you originally got this working) and try resetting and reauthorizing the script. If you're still not up and running can you post the exact error message you see when trying to update? Thanks.
I got the app working without any issues. Both the 1 day and the 60 day options worked. Now after trying it multiple times, I see that the one day option works but the 60 day doesnt work even though they call the same parent function.
Hi Rajat, The script saves authentication for the signed in user so if you switch accounts I would imagine that the script authentication does not match the user authentication. You'd need to clear the script settings and authorize again with the new user account.
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.