Possible to use Google scripts to integrate into Google Drive UI - google-apps-script

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.

Related

Limiting Google App Script permission to only access files it creates

Is it possible give a Google App Script permission to create files in a user's Google Drive, and then only have edit/delete access to those files, without having write access to any other files?
From what I can understand, the permission I need for this is drive.file under dependencies.enabledAdvancedServices[].serviceId, which is available in Google Drive API v3, but Google App Scripts only supports v2 (at least, as far as I can tell in the "Advanced Google Services" dialog).
Is there a way to get drive.file in GAS that I'm missing? Or has Google announced any plans to bring v3 into GAS? Or another way to restrict my script to only having write access on files it creates?

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.

How to Access / Run Google Apps Script (GAS) Functions from ordinary non-GAS web apps?

This is an alternate to the Google Maps V3 Full Integration API issue in my previous question.
I would like to give the user the ability to click a button, that then creates a new Google Spreadsheet, within their Google Drive, that allows them to save the data (JSON) that has been created while playing with my Mapping Application, into the new spreadsheet.
Later, the user can go to their Google Drive, open the spreadsheet, click a menu, open and populate my Maps App with their data from the spreadsheet. The user can edit the data either in the Spreadsheet or the Map and the changes go both ways.
Basically, I am looking for two way data binding between Google Maps V3 API and Google Spreadsheet that is very easy for a non-technical user.
It would seem that I should be able to write a GAS function and access it from my standard web page. How do you do that?
If I could convert my Maps V3 API app to GAS, the issues would be trivial, but until then an alternate workflow between Maps and Google Drive would be very helpful to allow users to save / collaborate their work.
If you deploy your Apps Script project as a web app you can have your application make requests to it over HTTP. The doGet() and doPost() handlers can both read request parameters, and using the ContentService you can return JSON or XML data. Likewise, inside Apps Script you can use UrlFetchApp to make HTTP requests to your application.

What does Google Picker API drivepreopen do?

I've noticed that some google drive apps fire POST request to https://docs.google.com/picker/drivepreopen?hostId=myhost upon file selection in picker dialog. Does anybody know what it does?
I need to be able to access my google docs files from my google drive app and I'm aware of the fact that drive apps can access only files it created or opened via context menu in google drive. As the name "drivepreopen" suggests maybe it allows you to programmatically invoke "open with"?
The Picker is how your app should be given access to a file and it can be used to display a list of the currently authenticated user's Drive files, as explained at https://developers.google.com/drive/integrate-open#open_files_using_the_google_picker.