Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created October 4, 2015 02:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolunet/f2ac1755cec306596dcb to your computer and use it in GitHub Desktop.
Save revolunet/f2ac1755cec306596dcb to your computer and use it in GitHub Desktop.
gapps execution api example
//
// creds.json is a service account json key
//
// -> always getting "The caller does not have permission"
//
var script = google.script('v1');
var key = require('./creds.json');
var jwtClient = new google.auth.JWT(key.client_email, null, key.private_key, ['https://www.googleapis.com/auth/spreadsheets'], null);
jwtClient.authorize(function(err, tokens) {
if (err) {
console.log(err);
return;
}
script.scripts.run({
auth: jwtClient,
scriptId: 'script-id',
resource: {
function: 'test',
parameters: []
}
}, function(err, response) {
if (err) {
throw err;
}
console.log('response', response);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment