This question already has answers here:
Can not run trivial app script bound to new blank document - get "This app is blocked"
(3 answers)
Closed 5 months ago.
I have created a custom function in a Google Sheet and I have given access to the Sheet to other users. But unfortunately the security settings of there company do not allow the users to unlock this script for their account.
This app is blocked. This app has tried to access confidential data in your Google account. To protect your account, we have blocked the access.
Is there any way that users can still run this script externally without having to install it themselves? So for example via a click on a button, which then starts the script in my account.
No, you won't be able to do that. The only way some code could be triggered by external users, but effectively executed by your account, would be in an apps script web app.
As you can see in the screenshot, there's an "Execute as" setting when you deploy an app that controls this behaviour:
I appreciate that this may not be an option for you, given that the current code is a custom function in a sheet. The only other approach would be to have the external users make a copy of the sheet, with its function(s), to run in their Google Workspace environment.
Related
I created a web app using Google Apps Script and sharing the link with editor access to other users is needed, otherwise, their input in the web app will not be recorded in the the spreadsheet connected to it.
My worry is if they manually edit the spreadsheet since they have editor access to it.
Is there a way to prevent them from editing the sheet manually?
Deploy the web app with the Execute the app as me option to run it under your account. You do not need to share the spreadsheet or the script with anyone.
See the Web App Demo answer for more information.
I created a small app on top of a spreadsheet (with GAS and HTML, CSS) and I deployed it.
Users can access to it without having to enter in the spreadsheet.
It works really well but i'm not able to see even the basic analytics (for eg. the number of viewers)
Thanks
Go to the project overview page. In the Google Apps Script web IDE, on the lefmost sidepanel click on Overview.
Also, if you have starred your project, go to https://script.google.com/home/starred
Rather than "viewers" you will see "users". If you have set your web-app as execute as you by anyone even anonymous, you will see only one user, you, as this page show the users that exectuted the scripts like the doGet function and the server-side functions called through google.script.run.
Note: https://script.google.com keep execution logs for the last 7 days. If you need to keep the logs longer you have to use another place to keep these logs, i.e. Cloud Logging (requires a Google Cloud standard project), Google Sheets spreadsheet.
Resources
https://developers.google.com/apps-script/guides/logging
Related
Effective way to debug a Google Apps Script Web App
This question already has an answer here:
Getting a list of active file viewers with apps script
(1 answer)
Closed 1 year ago.
So i have a google sheet table to store data of my team (name and gmail account). I will assign every user with different task in my project. I create a web app (user interface) using apps script so my user can interact with the task. In this case, assumes all my users will be using google chrome browser and need to login to the google account on their own browser. For users who use other browser or if not sign in to google account will be ignored.
If i deploy my apps script, is there any method to know which user is browsing it just by checking the google account they use. I don't want to create custom user/pass to login. I just want the script can detect by active google account to personalize the page so they don't need to see all available the task but only can see specific task that they are assigned to.
https://stackoverflow.com/a/66342797/16125139
This should help you
Session.getActiveUser().getEmail()
I have a Google Apps Script that I am currently using to successfully open a Google Sheets spreadsheet (read-only shared with my account) and perform some reading functions.
I received another spreadsheet that I would like to run similar processes on.
If I try:
SpreadsheetApp.openById("_______") (which works on the other sheet), I get Exception: Service Spreadsheets failed while accessing document with id _____" with this sheet. This spreadsheet is actually an xlsx on Google Drive (but appears it can still open in Google sheets) rather than a native Google sheet so I figured maybe that was the issue...?
So now I'm trying to instead access it as a Google Drive file using DriveApp.getFileById("____"). However now I get an authorization request to allow my script to access Google Drive. When I authorize it, I get:
This app is blocked
This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access.
I haven't found a way to fix this. I'm on a private Google account, not using a company's Apps.
Any ideas?
Found a solution to the permission issue.
To work with Apps Script, I've modified this from #alper's solution which sources #tellowkrinkle's comment.
Do the following:
Go to https://console.developers.google.com and create a new project for yourself
Search for the Google Drive API in the search box at the top, and turn it on
Click OAuth consent screen on the left and set it up.
Assuming your account isn't part of an organization, you'll have to say your app is for external users and in testing
In the required scopes section, add .../auth/docs and .../auth/drive (I'm not sure which needed, it's probably only one of those). This will probably not be available if you didn't complete (2)
Add the accounts you want to use with your copy of gdrive as testers of your app. Only these accounts will be able to use your copy of gdrive, so everyone will have to compile their own (unless someone goes and gets theirs reviewed by Google). I only added my own account because I am the only one using my App Script which uses my Drive.
Click the 3 dots on the top right and select "Project settings". Make note of the "Project number".
Go to your Apps Script. Go to Resources > Cloud Platform project. Insert the project number from (4).
Next time you try to run your Apps Script, you'll be asked to Authorize but this time you'll have the chance to actually do it successfully.
This question already has answers here:
Can I deploy bound scripts using Google Script API
(2 answers)
Closed 2 months ago.
I have a google sheet containing script, I want to perform following operations programmatically.
Make this Google spreadsheet public programmatically.
I want to execute the script associated with the above spreadsheet programmatically for any user (public).
Can I perform "Publish>Deploy as API executable" programmatically?
You may want to check the recent updates in Release Notes and see if it will help. It's stated:
You can now deploy a script project directly from the project manifest.
We've updated the Publish script editor menu item to more accurately represent the various kinds of deployments a project can have, such as add-on, web app, or API executable deployments.
For more information, you may want to check these references:
Using the Execution API
Publishing an Add-on
Then, for features not currently supported, you may check or file a feature request here.