If you are using Parallel process orchestration with HtmlService along with Database abstraction with google apps script you’ll need to know how to work with access tokens for oAuth2. Assuming you’ve used EzyOauth2 patterns to set up your application to be able to refresh tokens automatically, it’s fairly straightforward but you’ll need to be familiar with EzyOauth2 patterns and Datastore driver first.
The profile
{ "name": "DATASTORE", "functionName": "dataStoreTest", "skip": false, "options": { "driver": "cDriverDataStore", "parameters": { "siloid": "polymerdbab", "dbid": "xliberationdatastore", "peanut": "bruce", "disablecache": 1 } } }
dataStoreTest
function dataStoreTest (options, testData ) { // this will get an access token and pass it to doTheWork() return doGetPattern({} , constructConsentScreen, dataStoreTestRun,'googleDatastore',{options:options, data:testData} ); }
This is what htmlService will try to execute. If you recall from EzyOauth2 – taking some pain out of Apps Script API authentication, doGetPattern() simulates the authentication you’d expect with doGet() in a webapp without the need for user intervention by refreshing or reusing an unexpired access token. We also need to pass what doGetPattern() needs to do next – in this case call dataStoreTestRun(), and it has to pass the options and the testData that have been passed on from the profile and from the previous processing stage.
dataStoreTestRun
function dataStoreTestRun (accessToken,pass) { pass.options.parameters.accesstoken = accessToken; return bigTest (pass.options , pass.data); }
And here’s datastore running alongside all the other tests.
For more snippets like this see Google Apps Scripts snippets