mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
23 lines
479 B
TypeScript
23 lines
479 B
TypeScript
|
|
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();
|
|
|
|
return client;
|
|
}
|