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.
First let's look at the async profile. It's no different that the others except we are not going to run bigTest directly - first we have to get an access token and inject it, so we need to run dataStoreTest() which will do that, eventually getting round to running bigTest().
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.
This will be called by doGetPattern() after it has collected a usable access token. All we need to do is inject it into the options and execute bigTest as normal - just like all the other database back end tests that didn't need authentication.
And here's datastore running alongside all the other tests.
For more snippets like this see Google Apps Scripts snippets and for more on this topic, see Running things in parallel using HTML service
For help and more information join our forum,follow the blog or follow me on twitter .
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Script HTML service > Running things in parallel using HTML service >