Front-end Google Cloud products with a Google Apps Script application - Part 2

_________________________

This article improves the Google Apps Script engineering featured in earlier Bit Vectors articles herehere, and here to add file save and print features to a Google Apps Script application. This article will also discuss the potential of Google Apps Script application sharing.

Part one showed the sample application user experience.

Part two here will describe the application configuration.

Part three will explain the application engineering.

Part four will explore how Google Apps Script application sharing presently works and will explain why this is not yet ready for production, based on the present state of the Google Apps Script product. It will also discuss suggested feature enhancements to the Google Apps Script product that would make application sharing possible.

Download the three application component files from the GitHub repository.
____________________

Before starting on the application front-end, first build the associated BigQuery project as described here. Although parts of that process - the dialog boxes, steps, etc. - have changed since the original article publication, the core ideas remain. One new step involves Drive API configuration. At the Developer's Console, enable the BigQuery and Drive APIs. The process involves the same steps for both APIs; here, we'll focus on the Drive API. First search for the Drive API


1. Search for the Drive API for the project
and in this

2. Enable the Drive API
panel, click  Enable . Wait a few moments, and the API Manager will enable the Drive API

3. The Drive API is enabled
for the project. Do the same for the BigQuery API. Next, we'll need the Project ID. In the Cloud Console



4. The project ID value
look for the project ID value, circled and hidden here in Figure 4. In Google Drive


5. Build a new Google Apps Script application
build a new Google Apps Script application. At this point, the dropdown might not show the Google Apps Script pick. If this happens, click Connect more apps and in the dialog that opens, look for and add "Apps Script", and proceed.

When the Google Apps Script editor opens, name the project at the upper left. Drill down to

     File - > Project properties

6. Pick Project properties in the dropdown
to open this


7. Script properties: add the project Id
box, adding the Project ID value from figure four above.

Finally, in the script editor, drill down to

     Resources -> Advanced Google Services

to open the Advanced Google Services

8. Advanced Google Services
picker. Turn the BigQuery and Drive API's  on .

When the application first runs, its configuration will a few more steps. We'll look at them now.

When a user first deploys the application, this dialog


9. Application first run: authorization required
will open. Click "Continue" to open an authorization dialog

10. The authorization dialog
that shows an  Allow  at the bottom. Click that  Allow  to proceed.

Next, the application will probably want additional authorizations to use the Drive and BigQuery APIs. It might seem that the earlier steps would cover this, but they might not have. Google Apps Script can show the messages asking for these authorizations in two ways, and we'll cover both of them now.

When the application runs at this point, it could show an error message like


11. Message: enable the Drive API
this. For the Drive API, the second sentence of this error message has a URL pointing to this


12. Enable the Drive API
page. Enable the API and run the application again. If the web application form looks okay but nothing happens when you click  SUBMIT , switch back to the script editor. Drill down to

     View -> Execution transcript

and scroll down, looking for


13. URL to configure the BigQuery API
a failure message with a URL. Open that URL in a new tab, proceed as instructed, and run the application. Note that for this "extra" API authorization, either of these techniques should work.

The same Google account should "own" both the Drive and the Cloud resources used by the application. In other words, a single Google account should both own the application in and through Google Drive. That same Google account should also reference, or point to, a Cloud resource or resources used by that application. The OAuth2 machinery drives this security behavior.
_______________

Part two here described the application configuration. Part three will explain the application engineering.