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(); }