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.
Related
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.
We are using Google Workspace in my company and my boss explicitly shared a Google Sheet with me, so he is the owner and I have edit access. I am trying to create an App Script but when I try to access the Script Editor I always get the screen to request access on Google Drive.
Is it still possible to create a script or I am only allowed to create scripts in sheets that I am the owner?
According to Google's documentation on collaborating:
Access to bound scripts
Only users who have permission to edit a container can run its bound script. Collaborators who have only view access cannot open the script editor, although if they make a copy of the parent file, they become the owner of the copy and will be able to see and run a copy of the script.
So I just came across this issue.
Essentially I had my personal account and company account logged in on Google. For some reason, the Script Editor would try and access in with my personal account and when switching to my company account I would get the request access screen.
After logging out of my personal account I was able to create the script normally.
I made a new google sheet with a simple script that does an external call with UrlFetchApp.
However, when I try to run or test the code, it says authorization required. App needs permission. I then click on review permissions, followed by clicking on my Gmail account.
Sign in with Google temporarily disabled for this app
This app has not been verified yet by Google in order to use Google Sign In.
Any advice on how to resolve this? Why is this showing up for my own unpublished unfinished code?
Reasons
Making external calls is a sensitive scope. If by any chance you tried to authorize from any (reauthorizations count as well) account 100 times (see user cap help page) throughout the development process, you will not be able to proceed.
That is usually the primary reason for this screen, but sometimes you get locked even if the project is new (for example, for some G Suite accounts). If that happens, in my experience the only way to fix it is by going through the review.
There is also a thread on the issue tracker if cannot resolve it with methods listed below.
Finally, take a look at related Q&As:
"Sign in with Google temporarily disabled for this app" error when trying to authorize a script
How can I bypass "Sign in with Google temporarily disabled for this app" in a Google Sheets script?
How to fix
Switch the Google Cloud Platform Project to a new standard one. This will reset the counter.
Create a new bound script from a new Google Sheets spreadsheet (this works the same as switching GCP, as a default cloud project is assigned to the script project).
Go through the OAuth verification process. Don't worry, it is not that long and only requires a video of how you use the scopes.
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
I have a google sheet that has a script embedded.
In the script > resources > cloud platform project, I have added and linked a project to this script to enable the APIs. This works great in the current Google Sheet.
Challenge:
When I make a copy of the Google Sheet the Cloud Platform assigned project is lost and it requires users to enable these permissions again.
Is there a way to prevent this from happening? Am I missing a setting?
What you're trying to do is not possible. Even if you try making a copy of a standalone script that has a GCP project associated, you will get the same functionality (no GCP project associated).
Also, it makes sense that each new user that runs the script has to explicitly authorize the APIs to make changes in their files, send emails on their behalf, or what have you. It's a basic step in the 3-legged OAuth 2.0 workflow, and it can only avoided if you use a Service Account.
So in your situation, I would just use Advanced Google services, even if each new user has to grant authorization. In the end, the appropriate advanced services are automatically enabled in your copied project; users don't need to enable them manually, only grant them authorization.
Reference:
https://developers.google.com/identity/protocols/OAuth2
https://support.google.com/a/answer/2538798?hl=en