✨ feature: Enhance output options with Google Sheets integration and improve Excel writer functionality
This commit is contained in:
+9
-1
@@ -10,6 +10,14 @@ import { NewsletterMessage } from '../parsing/types.js';
|
||||
const gmailScopes = ['https://www.googleapis.com/auth/gmail.readonly'];
|
||||
|
||||
export async function authorizeGmail(credentialsPath: string, tokenPath: string) {
|
||||
return authorizeGoogleOAuth(credentialsPath, tokenPath, gmailScopes);
|
||||
}
|
||||
|
||||
export async function authorizeGoogleOAuth(
|
||||
credentialsPath: string,
|
||||
tokenPath: string,
|
||||
scopes: string[]
|
||||
) {
|
||||
const credentials = JSON.parse(await readFile(expandHome(credentialsPath), 'utf8'));
|
||||
const clientConfig = credentials.installed ?? credentials.web;
|
||||
const oauth = new google.auth.OAuth2(
|
||||
@@ -22,7 +30,7 @@ export async function authorizeGmail(credentialsPath: string, tokenPath: string)
|
||||
oauth.setCredentials(JSON.parse(await readFile(expandHome(tokenPath), 'utf8')));
|
||||
return oauth;
|
||||
} catch {
|
||||
const url = oauth.generateAuthUrl({ access_type: 'offline', scope: gmailScopes });
|
||||
const url = oauth.generateAuthUrl({ access_type: 'offline', scope: scopes });
|
||||
const code = await waitForBrowserCode(url);
|
||||
const { tokens } = await oauth.getToken(code);
|
||||
oauth.setCredentials(tokens);
|
||||
|
||||
Reference in New Issue
Block a user