I have a google sheet and created an app script by clicking on the extensions -> "Apps Script".
I imported the App Script in the Google sheets using Macro -> "Import Macro" and thus triggered it with the click of a button.
Everything works ok but when I share this sheet with editor access to a Microsoft account, the Microsoft account indeed can edit the content of the sheet but is not able to run the app script by clicking on the button.
First of all, sheet requests the permission to run the app script].
After clicking "Continue" it results in the error "Something went wrong".
Does Google not allow the running of scripts by a non-Google account user?
Is there any way to allow non-Google / workspace users to run the script?
Does Google not allow the running of scripts by a non-Google account user? Is there any way to allow non-Google / workspace users to run the script?
Short answer is no.
Longer answer is that in order to run a script the script needs to be authorised to run as somebody. If the person doesn't have a Google account then there is no account to authorise the script and so it can't be run.
Related
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.
I made a simple Telegram bot that runs on Google Spreadsheet with a help of Google Apps Script.
It does a lookup in sheets and optionally saves an uploaded file to my Google Drive.
Previously it was a Script attached to the Spreadsheet. Later Google suggested to create an App in Google Cloud Console and assign the script to that App id, so all API calls are accountable.
Script app is not verified and runs in "Publishing status: Test" mode. I only need it to access my account's data.
The permissions I gave to the script (access to Sheets, Drive) get automatically revoked without any notice after about 2-3 days, and the bot stops working. Until I revisit the Shpreadsheet, open Extensions - Apps Script, run any function and it asks for authorization again. Then the bot works for a couple of days more.
How can I make the permissions I give permanent?
Permissions I granted (again) to my app:
Updated menu of the Spreadsheet app:
From Setting up your OAuth consent screen > Testing
Authorizations by a test user will expire seven days from the time of consent. If your OAuth client requests an offline access type and receives a refresh token, that token will also expire.
Considering the above you have to get your app to be verified by Google.
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.
I am using Google Sheets as an online database for six users. It has buttons that run scripts mainly to hide/unhide sheets. People I share it with, tell me they require permission or authorization when they activate the button to run the script. I don't know how to grant permission. Can anyone help, please?
the script is attached to your spreadsheet and at some point, you authorized the script for your spreadsheet. now if you share that spreadsheet then all your people will need to do the same - authorize the script for a given spreadsheet for themselves (in other words, they need to allow running those scripts because all non-authorized scripts are by default disabled).
prompt them to enter script editor and press run button (triangle-shaped). a window will pop up with the question if they want to authorize those scripts. when they do they can use those scripts too.
if you are advanced script user you can set up an installable trigger for your spreadsheet to ease this process
Years ago I setup a Google Apps Script to allow me to "snooze" emails in Gmail. I have recently closed that Google Apps account. I am now simply forwarding all emails for that domain to another account that I have. I forgot to stop the Google Apps Script before closing my Google Apps account. I am now getting App Script Notification emails telling me that my Google Apps Script has recently failed to finish successfully. But, I do not see a way to stop this script from running.
To stop Apps Script from accessing your data, you need to revoke it's access.
Here are the steps on how to do that:
Visit the permissions page for your Google account. (To navigate to this page in the future, visit Google.com, then click your account picture in the top-right corner of the screen. Next, click Account, then Security, then View all in the account permissions section.)
Click the name of the script whose authorization you want to revoke, then click Revoke access on the right.
Check also this page for more information.