Working with Google App Script

1 minute read

Google App Script

Google Apps Script is a JavaScript development platform, where you can do more with Google products.

The following examples are taken from Google App Script’s page:

  • Add custom menus, dialogs, and sidebars to Google Docs, Sheets, and Forms. Write custom functions and macros for Google Sheets.

  • Publish web apps — either standalone or embedded in Google Sites. Interact with other Google services, including AdSense, Analytics, Calendar, Drive, Gmail, and Maps.

  • Build add-ons to extend Google Docs, Sheets, Slides, and Forms, and publish them to the Add-on store.
  • Convert an Android app into an Android add-on so that it can exchange data with a user’s Google Doc or Sheet on a mobile device.

  • and more

Besides the online App Script editor, it is more convienient to develop and manage Apps Script projects from your terminal. This can be achieved by using an open-source tool called clasp.

Authenticate Clasp to run app locally

https://github.com/google/clasp/blob/master/docs/run.md

Setup your local environment

  • Login globally
clasp login

How to change source

  • Make changes locally
  • Then
 
clasp push

to push changes to script.google

  • Commit to github

How run functions

  • Make sure you are logged in with clasp login --status
  • If not login locally, you should ``clasp login –creds creds.json`

The creds.json can be obtained from https://console.developers.google.com/apis/credentials?project=ID by downloading OAuth 2.0 Client IDs for application Clasp.

  • Then
clasp run

Open webapp

clasp open --webapp