From c0e4b5f3838a4fe34e8097eec37079f0bf354c7b Mon Sep 17 00:00:00 2001 From: Vladimir Korobov Date: Fri, 5 Jun 2020 19:02:04 +0300 Subject: [PATCH] add impersonateAs option for useServiceAccountAuth --- lib/GoogleSpreadsheet.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/GoogleSpreadsheet.js b/lib/GoogleSpreadsheet.js index 28ff27f..ea463b7 100644 --- a/lib/GoogleSpreadsheet.js +++ b/lib/GoogleSpreadsheet.js @@ -72,11 +72,13 @@ class GoogleSpreadsheet { } // creds should be an object obtained by loading the json file google gives you - async useServiceAccountAuth(creds) { + // impersonateAs is an email of any user in the G Suite domain that has delegated domain-wide authority to the service account + async useServiceAccountAuth(creds, impersonateAs = null) { this.jwtClient = new JWT({ email: creds.client_email, key: creds.private_key, scopes: GOOGLE_AUTH_SCOPES, + subject: impersonateAs }); await this.renewJwtAuth(); }