Skip to content

Commit

Permalink
add impersonateAs option for useServiceAccountAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Korobov committed Jun 5, 2020
1 parent 95c3271 commit c0e4b5f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/GoogleSpreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit c0e4b5f

Please sign in to comment.