This describes how to authenticate with Google Datastore using Goa along with a service account, as described in Oauth2 for Apps Script in a few lines of code (which you should read first for background) and Goa services and customization
The library, cGoa, is available under this project key.

MZx5DzNPsYjVyZaR67xXJQai_d-phDA33

Setting up

You’ll need to create an App. The dashboard/developers console can be found here. This time, its a service account that’s required.
Your one time setup would look something like this. In this case – a service account, the credentials come from the JSON file downloaded from the Google developer console and identified by the given file id.

The example

The example includes 3 functions.
  • A doGet example for a web app.
  • An example where the token has already been setup by a one off doGet example
  • An example of consuming the token
The doGet should be published
There is no consent screen required or created for a service account.

The patterns

An example of using cGoa for copying to a DataStore using Driver DbAbstraction is shown in the slides below.

For more like this, see OAuth2 for Apps Script in a few lines of code

Why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available.