0👍
Try something like this make sure to configure domain wide delegation to the service account from your workspace account.
subject is the user on your domain you want the service account to impersonate.
let google = require('googleapis');
let privateKey = require("./privatekey.json");
var jwtClient = new google.auth.JWT({
email: privateKey.client_email,
key: privateKey.private_key,
scopes: ['https://www.googleapis.com/auth/calendar'],
subject: 'user@domain.com'
});
jwtClient.authorize(function (error, tokens) {
if (error) {
console.log(error);
return;
}
else {
console.log("Successfully connected!");
}
});
Source:stackexchange.com