Google spreadsheet on team drive not running script - google-apps-script

I have a google form on my Team Drive that when submitted pulls that data to a spreadsheet. I used a script within that spreadsheet that pulls the unique URL to that specific submitted form. My team members are able to submit the form and access the spreadsheet for editing, however the script only runs for me. All of my team members have full access to the drive. I have scoured as far as I know how to resolve this issue but have only come to potential answers. One of those answers was to publish the script as a web app or API executable. This is a little out of my scope but would love to get this working for my team as it is extremely useful. Not to mention I could relay this information to other projects if I can get it resolved. Any input would be greatly appreciated!

If you have created a script then publishing the script is not that difficult. See the link here to see how to do it (See deploying a script as a web app: six simple steps!)
Also from the documentation: When a web app in a Team Drive is deployed, choosing to "execute as you" causes the web app to execute under the authority of the user that deployed it (since there is no script owner).

Related

Apps Script (Google Sheet) not allowing me to Run Script

I have a fairly simple dataset in a Google Sheet. I created an AutoSort script. I saved it, and when I click "Run," I get the following errors. One from a pop-up, and another from the Execution Log.
Pop-up error:
Authorization required
This project requires your permission to access your data.
*For this error, there is a button to "Review Permissions" and I log in using my google account and then just nothing happens.
Execution Log error:
Warning This project requires access to your Google Account to run. Please try again and allow it this time.
The Owner of this Google Sheet is my personal Gmail account, and I am making these edits and created the script using my business Gmail Admin account. I also tried to access this sheet and run the script USING my personal Gmail account, and received the same error:
Google hasn’t verified this app
The app is requesting access to sensitive info in your Google Account. Until the developer ({mypersonalemail}#gmail.com) verifies this app with Google, you shouldn't use it.
Any insight as to how I can authorize this would be appreciated. It sounds like something small I'm missing.
Also, in my personal email I receive a message with subject:
Review edits to your Apps Script project within your document
and it allows me links to access the worksheet and the script, but I don't see any way to approve the edits, or anything like that.
Expected behavior: What I am expecting is for the script to Run, when I click "Run."
It's not a good idea to mix accounts from different domains, specially when using a free account and a Google Workspace account like you have done because that is the cause of the situation that you are facing.
My hypothesis is that the Google Cloud default project linked to the bounded script is created with the account used to create the project.
If you need that you personal account be the spreadsheet owner the best is to create the script using the personal account, and when needed, create a Google Cloud Standard project (GCSP) using the the personal account. You might try to fix the problem with your spreadsheet and the current Apps Script project by creating a GCSP, as was mentioned previously, by using the account that is the owner of the spreadsheet and linking it to the Apps Script project.
Note: If your script is using sensitive scopes you might have to set the OAuth Consent Screen publishing status to tes and add your Google Workspace account as tester.
Ref: Setting up your OAuth consent screen
Once you have finished the setup of your Google Apps Script project you should be able to use your Google Workspace account to update and run the Apps Script code but any new deployment and new version should be done using your personal account.
If you have access to Shared Drives and are allowed to use them for your spreasheet, consider to move it to a Shared Drive as this will make a lot easier to manage your script.

Google Sheets Script Approval

I have created a spreadsheet that uses a simple script to make buttons function. The sheet has become very popular and I am getting tons of downloads daily - but some people are afraid to "allow" my script because how awful Google makes it sound (I totally understand it, but it keeps saying it is not approved and could be malicious and so on).
How do I go about getting the script approved? I thought I did the right steps but never heard anything.
My spreadsheet is always evolving and new versions might have changes to the script, so will I have to get new approval every time I update the sheet?
Tl; Dr
Create a Google Cloud Standard Project and take note of the project id
Complete the OAuth Consent Screen. At this end of this, it will be sent to verification
Add the project id to the Google Apps Script project
For the detailed instructions go to the official help articles (listed below)
References
Cloud Platform Projects
Authorization for Google Services
OAuth Client Verification

Where can i see the analytics of an Google App Script Deployment?

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

Can not grant access to run scripts from kid account in google spreadsheet

I made a fun spreadsheet to exercise basic math for my kids, but when they are logged on their kid account, they can not run any scripts (no fancy script, just copy-paste macro). After script authorization request they got error 403.
Chyba 403: access_denied
Podrobnosti požadavku
access_type=offline
login_hint=hanzalek.ben#gmail.com
o2v=1
hl=cs
response_type=none gsession
redirect_uri=https://script.google.com/oauthcallback
state=14621511234839642112
client_id=433541798399-h1ncj2ckkapf2gkcoo59mjv46kem0c88#developer.gserviceaccount.com
display=page
prompt=consent
scope=https://www.googleapis.com/auth/spreadsheets.cu
When I access the spreadsheet from another adult account everything runs.
link to the spreadsheet (you may copy it and use it for your kids if you wish :):
https://docs.google.com/spreadsheets/d/1Jy1hHgyCkkIJv26attxikKpJlYb_hjWXTauXMjVyn8E/edit?usp=sharing
Answer:
It appears that there is a restriction for Kid/Child accounts where Apps Script it not available. As long as your children have restricted accounts, there is nothing you can do about this.
More Information:
I did some testing and was able to reproduce the behaviour. These are the results of my tests:
If the account is a child account, the 403: access_denied error is received when trying to run a script from a Spreadsheet.
If the account is a child account, even if they create a new Sheet themself, they do not have access at all to the script editor. This heavily implies that child accounts do not have any Apps Script permissions/abilities at all.
If the account is not a child account, but the account is set up to be supervised in the family group at https://families.google.com/families, they can both run the script written by another account, and they have access the Script editor.
After searching the Family Link settings for the kid account, I was not able to find any setting which allows this to be turned on. I did some searching and I wasn't able to find any specific documentation either from searching on Google or on Google Help.
I did however find a couple of other Stack Overflow questions in which people have had the same error, and this was also the result of their findings, which I have included below.
Google Issue Tracker:
As there doesn't seem to be anywhere that publically mentions this specific Apps Script restriction, I suggest that you file a bug on Google's Issue Tracker for this, in the linked Apps Script component. They might be able to give you more insight into this behaviour.
In the mean time, it appears the only workaround for this is to have the users of the kids accounts use non-kids accounts while using these Spreadsheets, or maybe looking into embedding the Spreadsheet in a web app and have the scripts execute as you rather than the currently logged-in user. More infor about this can be read here
Relevant Questions:
New Google Account not able to access script.google.com
“Can't visit this page” error when trying to access Google Scripts
References:
Your family on Google
google "kids" apps script 403 - Google Search
Search results for kids apps script 403 - Google Help
Google Issue Tracker
Web Apps | Apps Script | Google Developers

reuse script or publish a private google sheets script add-on without gsuite or being a business

I'd like to reuse a Google Apps Script between multiple sheets on my personal Google account without publishing the script publicaly. One approach that I'm trying to avoid is to simply copy and paste the script between each sheet that I'm using.
After some reading my impression is that this is typically done by publishing an add-on. I am also under the impression that this can (or could) be done privately, so that no code review is needed and you don't need to pay anything. Most of the related questions I've found on SO seem to have out of date answers (chrome web store instead of GSuite Marketplace) or are too simple (share by publishing an add-on) or refer to gsuite users/admin, etc.
Assuming I need to publish an add-on to get easy sharing across all of my sheets I'm told I need to convert my project to a Google Cloud Project. So I created a Google Cloud Project and then went to transfer my code to that project by going to "Resources - Cloud Platform project" and entering my project number. However, when I do that it tells me that I need to enable oauth for the project and it takes me to a page which looks like it will require formal code review.
I am under the impression that private publishing may be possible if I am an organization. So I went back to the Google Cloud Console and tried to create an organization. Here however, it seems like either I need to be subscribing to GSuite or I need to enable Cloud Identity. The latter seems only pertinent to businesses as during the sign up it asks me for my business name and business domain (e.g. jims-business.com); I stopped when it asked me for my domain.
So again, my question is, is it possible to share a Google script between multiple sheets on my personal account without making a public add-on? After way to much time reading through Google terminology my impression is no, but I'd be happy to be proven wrong!
You don't need to be a G Suite user to publish an add-on, but you do if you want to do it as "internal only", as it requires a valid domain.
I'm afraid you will have to copy the same Script for each file and use an onOpen function.