View and audit all App Scripts on GSuite domain - google-apps-script

Is there a way for me to be able to view and audit all app scripts created in my gsuite domain being an admin, without it being shared with me? I know that I'm able to pull all files in drive using vault and I assume if the app script files were still in drive, I could probably have searched for them that way, but that doesn't work anymore.

Yes, you can use Vault to search for the Scripts projects. The GAS files will display this icon next to the script title https://ssl.gstatic.com/docs/doclist/images/mediatype/icon_1_script_x16.png
You can use Vault to download it but it will be a json file, you can't preview the GAS JSON file but you can use the Drive API to import it to your own account, more info at Import Google app script project from JSON file

Related

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

Opening a file on Google Drive directly in a Google Drive App

If I open the shareable link I have got for a file from Google Drive in the browser, I always get either to the Drive's internal preview program or to a download page (See below).
I would like to know whether there is a programmatic way to launch a specific drive-connected application (with confirmed access permissions) to open a file for which I have the link (and thus, the ID as well).
I don't want to do this through the drive's interface, but rather within my program. Let's say I want to let the users browse their files and open them in the browser with their default app as they have defined it on their drive (and let's say I already know that app).
To make it clear, I just want to achieve what Google Drive's interface does in the browser: You click a file, and it opens in a new tab in your default app.
In my opinion, this is possible with the use of Advanced Drive Service and Drive Service.
Advanced Drive Service
The advanced Drive service allows you to use the Google Drive web API in Apps Script. Much like Apps Script's built-in Drive service, this API allows scripts to create, find, and modify files and folders in Google Drive. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including access to custom file properties as well as revisions for files and folders.
and for the Drive Service, you can use getUrl() method to get the URL that can be used to open the File in a Google App like Drive or Docs.
This service allows scripts to create, find, and modify files and folders in Google Drive.
Detailed information and sample codes regarding these services can be found in the documentations.

Is there a way to build an Google Apps Script application that uses BigQuery Service as a service account instead as a user?

What I trying to do here is an application that connects to bigquery, executes some query and writes a spreadsheet in current user's Google Drive.
I know that I can change the "Execute app as" option when deploying the app. But when I do this, and the user try to use the app, Google asks for permission to access the BigQuery.
I do not want to give permission to each user to access BigQuery.
We have about 50 ~ 100 users who will use (and this number can increase)
Some images:
When access the application's url: http://i.imgur.com/kGzJ3ps.png.
When the user clicks in the "continue" button:
http://i.imgur.com/4cRmhZ6.png
Hope I've been clear.
You would probably need an App, that had people sign in with their Google account using oAuth2
Google Accounts Authentication and Authorization
I think that this link gives an overview of what your options are:
Permissions and Types of Scripts
I guess you would need to have an App, that ran as User at the keyboard, so that the spreadsheet saved to their Google Drive. If you wanted the user to be able to download a file to their computer drive, that's a little different.
Just use HTML Service. It's basically just building a website. You just don't have a domain name. But the spreadsheet you are distributing doesn't have a domain name.
HTML Service Google Documentation
From an Apps Script HTML Service, you can write to Spreadsheets, Documents, and run HTTP Requests (urlFetch).
URL Fetch Service
The permissions in the Apps Script App can be set to run the Apps Script file as yourself, with access to anyone, even anonymous. That way, the user will never be asked for permission for any files that you own. You will need to authorize it once, the first time any script that needs access to your files is run.
Because anyone could run your Apps Script App, you might want to have a log in system to authenticate users.
You would need to use the Big Query API with Apps Script urlFetch to access Big Query.
So, with the HTML Service, you can do most everything you could do with HTML, CSS, and Javascript on a regular website. You can create custom input forms, have different pages and display data in tables. Plus it's served over HTTPS.
One solution that you can use if you don't want all your users to enable BigQuery is to use a webapp deployed as a service running as "you" and that will respond to an urlFetch coming from each user through the script they run as "themselves".
This service will be deployed as any other webapp using a doGet main function and return its data using contentService
Yes, that is possible. Check out this answer here: Using Advanced Google Services with Service Account and also check this awesome library: https://github.com/googlesamples/apps-script-oauth2

Possible to use Google scripts to integrate into Google Drive UI

Is it possible to use Google apps scripts deployed as a web app to integrate into the Google Drive UI?
i.e. opening files similar to: https://developers.google.com/drive/about-sdk#create_and_open_files_directly_from_the_drive_ui
But using Google scripts: https://developers.google.com/apps-script/
Scripts do have access to a drive api, but I'm unsure if they have the capability to integrate into the Drive UI?
Yes. You can create a script, deploy it as a web app and call it from the Drive UI as shown in the link you provide. Your script is passed parameter from the Drive UI (including for example, the folder currently selected) and you work from there... I use this mechanism to work with a folder structure representing client activity. Selecting a client folder, I can choose to open with my script or the usual Drive options. My script checks the parameters passed by drive and responds with an appropriate user interface for the next step.

Granting APP authorization to Google Drive files

I am trying to authorize files on my google drive with specific APP authorization I created. As files on my google drive can only be manipulated by its authorized app, is there any way I can convert these "None" authorized file with APP authorization? And, if yes, by which function?
I looked all over the tutorial document but only find discussion about permission. The only method I can think about is uploading these files to google drive with upload function from my created app. But I guess there is a much smarter way. Do any one has the same experience?
Here list my steps to create authorized file:
First, I start my app from using sample code, DrEdit. https://developers.google.com/drive/examples/python;
From the code, I successfully open new files and saw them listed on my google drive.
From view authorized app, I can clear see these apps created from my app have their authorization signed with app ID. The other files original belong to me have these authorization signed as "None".
I had the same issue and had to change the scope from https://www.googleapis.com/auth/drive.file to https://www.googleapis.com/auth/drive which gives full access to all drive files rather than just the ones created by the app.