Summary
This is a wrapper for the Google API Client Library, providing opinionated syntactic sugar for client authentication and making requests to a Google Apps Script via the REST Execution API
See: https://developers.google.com/apps-script/guides/rest/quickstart/js
Basic Usage
In your html, include the browser build gapi-nano.js
from the dist
directory after https://apis.google.com/js/api.js
Then in another script below that, pass in some options to gapiNano.init
to get started
Functions
- init(options, authListener) ⇒
undefined
init - loads and authenticates gapi client using Auth2
- run(fName, parameters) ⇒
Promise
run - calls a function from the script specified by scriptId option during init()
undefined
init(options, authListener) ⇒ gapiNano.init
- loads and authenticates gapi client using Auth2
Param | Type | Description |
---|---|---|
options | object |
Auth2 options, including clientId and scope |
authListener | function |
(optional) callback with a single boolean parameter, called whenever the authentication status changes |
Promise
run(fName, parameters) ⇒ gapiNano.run
- calls a function from the script specified by scriptId option during init()
Returns: Promise
- a Promise object resolved with result of the function call
Param | Type | Description |
---|---|---|
fName | string |
the name of the function |
parameters | object |
(optional) the arguments passed to the function |
Building Changes
To rebuild dist/gapi-nano.js
from index.js
, use the npm task:
$ npm run dist
Of course this requires browserify
to be installed globally:
$ npm install -g browserify