Comments
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.
Hi.
This code works great. I deployed the code as a web app and am able to populate the History sheet when running the link in-cognito mode using same email to login as the email I used to make the sheet. I was curious to know if someone else uses this deployed link i.e. use some other email id for authorization. I tried that, it threw error Error: Access not granted or expired. (line 454, file "Service").
Can you help?
Hi Momo - yes, if the user signs into the sheet with their account and authorizes it will read their data. I wrote this as a means to get your own data and there are some considerations if you share with someone else, for instance if you give them edit permission to the sheet they will be able to see your secret API key in the script. Generally OAuth is designed for this kind of flow where a user can delegate access to a trusted app. Depending on what you're trying to build Google Sheets might not be the best tool.
I am new here!
Can I use this code and the AOuth2 get someone's google fit data with his authorization ?
Could you give me some suggestions,Please? Thank you very much!
Thanks so much for this, worked first time flawlessly. Now to import the data into Grafana.
Thank you again for writing up such a detailed explanation of steps that were so easy to follow.
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.