No Such User when trying to access google apps script editor - google-apps-script

In my Google spreadsheet, when I go to "Tools->Script Editor..", I get a page saying "No Such User" Error. Any idea how to fix this?
I figure this could be a permissions issue, but not sure how to change permissions if required.

Finally i found the solution accidentally.
The issue is resolved by enabling GoogleAppsScript as part of your drive.
Open Google Drive in your web browser.
Click New > More > + Connect more Apps
and then select GoogleAppsScript.
Once i did this going back to script editor of my spreadsheet, no more gives any error.
Here is the link which contained this step:-
https://developers.google.com/drive/v2/web/quickstart/apps-script
Also there is additional problem about Invalid OAuth Client when trying to run the script. which i faced since each apps script has to be attached to a Google Cloud Project. This is accessible only to the person who originally created the file even after its in the team drive. In which case, you need to make a copy of the apps script available by going into File->Make a copy. And then in the Resources drop down , you will see Cloud Platform Project, upon clicking it you can now give the project number of the Google Cloud Platform project you created on console.cloud.google.com.

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.

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

Unable to open Google xlsx spreadsheet / Also Google Drive permission Blocked

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.

View/Manage Web Apps published through Google Apps Script Editor

Is there a way to view & manage the scripts I have deployed as a web app through the Google Apps Script Editor?
I stored a script on my google drive, opened it with Google Apps Script, and deployed via 'Publish -> Deploy as Web App'. After testing the script/webapp works correctly, I deleted the script project from my google drive and found that the web app is still functioning.
I can't find a way to view a list of, or manage the scripts after they have been published. Is there a console or dashboard that will show all my published scripts?
The file may still be available in the Trash or Archives folder. Searching for type:script will give you a list of all stand alone script files. Also type:script is:trashed will find any in the trash folder.
Finding files with bound scripts associated (the script is embedded in the file) as well as any with specific permissions can be done by looking at your account's permissions. This will list every file that has had some sort of permission request. If a bound script does not require any permissions granted, I know of no way to finding the file. To see the files you have granted permission to, use this link: https://myaccount.google.com/permissions

Queries done in Sheets pulling from BigQuery (permissions help needed)

I want to set up scripts in sheets creating several menu options for predefined queries. This way normal bob can get his queries, Tina can get hers, and Fredrick in accounting can get the information he needs without out writing his own queries. They can use a fun menu:
screenshot
The data table is set up in BigQuery, and queries work fine using the 'compose query' option. The issue is getting queries written in the script to function in sheets. Here is a nice tutorial by Ido Green on how to go about it. https://greenido.wordpress.com/2013/12/16/big-query-and-google-spreadsheet-intergration/
My problem is getting the permissions to work. I believe I approved the project ID in BigQuery, but I am unsure of how to do this in Drive. This is new to me. Let me know if someone has the step by step. This is the error I get when I try to run the script:
"Exception: No suitable credentials found to access Google Drive. Contact the table owner for assistance."
Thank you for your help
Got the same issue with my Google Apps script.
Steps to fix
Enable Google Drive API in Resources -> Advanced Google Services
Enable Google Drive API in Google Developers Console for this project
Run 'DriveApp.getRootFolder();' to get Drive Auth Scope .
I think the problem is in the OAuth Scopes.
According to this SO question, If you are using the BigQuery web UI and have not explicitly granted access to Drive, it won't work. For example, the first time I tried to "Save to Google Sheets", the BigQuery UI popped up an OAuth prompt asking me to grant access to my Google Drive. After this it could save the results. Try doing this to make sure your credentials have the Drive scope and then "Save View" again.
If you are using your own code to do this, you should request scope 'https://www.googleapis.com/auth/drive' in addition to the 'https://www.googleapis.com/auth/bigquery' scope you are already using to talk to BigQuery.
Also check this SO question and this community page for more information.