Extend googleApi credentials to support user impersonification (#1304)

*  Extend googleApi credentials to support user impersonification

*  Add service account authentication to Gmail

*  Minor improvements

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza
2021-01-10 14:49:47 -05:00
committed by GitHub
parent a7dee0aba7
commit 76cee5577b
6 changed files with 130 additions and 6 deletions

View File

@@ -66,6 +66,8 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
} else if (error.response.body.error.message) {
errorMessages = error.response.body.error.message;
} else if (error.response.body.error_description) {
errorMessages = error.response.body.error_description;
}
throw new Error(`Google Drive error response [${error.statusCode}]: ${errorMessages}`);
@@ -107,7 +109,7 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
const signature = jwt.sign(
{
'iss': credentials.email as string,
'sub': credentials.email as string,
'sub': credentials.delegatedEmail || credentials.email as string,
'scope': scopes.join(' '),
'aud': `https://oauth2.googleapis.com/token`,
'iat': now,