n8n/packages/nodes-base/nodes/Google/GoogleApi.ts

24 lines
494 B
TypeScript
Raw Normal View History

2019-10-27 13:44:21 -07:00
import { JWT } from 'google-auth-library';
import { google } from 'googleapis';
/**
* Returns the authentication client needed to access spreadsheet
*/
export async function getAuthenticationClient(email: string, privateKey: string, scopes: string[]): Promise <JWT> {
const client = new google.auth.JWT(
email,
undefined,
privateKey,
scopes,
undefined
);
// TODO: Check later if this or the above should be cached
await client.authorize();
2020-01-27 01:32:47 -08:00
// @ts-ignore
2019-10-27 13:44:21 -07:00
return client;
}