The VBA API generates REST API requests from your VBA function calls, and needs a Google Apps Script handler to service those requests by communicating with the required scriptDB instance.
Typical Handler code
It is unlikely you will need to make much changes to this code when you come to write your own handler, aside from to adjust the scriptDB dispatcher library reference, and to adjust the type of access based on the user keys. In this case I’m only allowing read operations, regardless of who is accessing.
// this is a handler for cScriptDbCom requests. // requests to this script should be authenticated with oAuth2 // 2 further authentication parameters are expected in the head of each request, modelled on the parse.com API // {"X-scriptDb-Application-Id":"somekey","X-scriptDb-REST-API-Key":"someotherkey"} // these can be used by the caller to decide whether to allow the type of access being requested var dispatcher = "scriptDbDispatch"; var whatsAllowed = ['query','count','getbyid']; function doGet(e) { return ContentService .createTextOutput(scriptDbCom.makeContent(e,"GET",whatsAllowed,eval(dispatcher +".getDb")(e.parameter.library))) .setMimeType(ContentService.MimeType.JSON); } function doPost(e) { return ContentService .createTextOutput(scriptDbCom.makeContent(e,"POST",whatsAllowed,eval(dispatcher +".getDb")(e.parameter.library))) .setMimeType(ContentService.MimeType.JSON); } function workAround() { var x = ScriptDb.getMyDb(); x.count({}); }
Private handler
var whatsAllowed = ['query','count','getbyid'];
For help and more information join our forum, follow the blog or follow me on Twitter