diff --git a/apps/x/packages/core/src/auth/providers.ts b/apps/x/packages/core/src/auth/providers.ts index edae93d7..40ef6f4a 100644 --- a/apps/x/packages/core/src/auth/providers.ts +++ b/apps/x/packages/core/src/auth/providers.ts @@ -77,8 +77,10 @@ const providerConfigs: ProviderConfig = { scopes: [ 'https://www.googleapis.com/auth/gmail.modify', 'https://www.googleapis.com/auth/calendar.events.readonly', - 'https://www.googleapis.com/auth/drive.readonly', - 'https://www.googleapis.com/auth/documents', + // Full Drive access: read/export Google Docs to .docx AND write the edited + // .docx back into the original doc (files.update needs write, which + // drive.readonly does not grant). Covers list/get/export/update. + 'https://www.googleapis.com/auth/drive', ], }, 'fireflies-ai': { diff --git a/apps/x/packages/core/src/knowledge/google_docs.ts b/apps/x/packages/core/src/knowledge/google_docs.ts index 8558f571..0a694efd 100644 --- a/apps/x/packages/core/src/knowledge/google_docs.ts +++ b/apps/x/packages/core/src/knowledge/google_docs.ts @@ -5,9 +5,10 @@ import { google, drive_v3 as drive } from 'googleapis'; import { resolveWorkspacePath } from '../workspace/workspace.js'; import { GoogleClientFactory } from './google-client-factory.js'; +// Full Drive scope: export Google Docs to .docx (read) and write the edited +// .docx back via files.update (write). drive.readonly can't do the write half. export const GOOGLE_DOC_SCOPES = [ - 'https://www.googleapis.com/auth/drive.readonly', - 'https://www.googleapis.com/auth/documents', + 'https://www.googleapis.com/auth/drive', ] as const; export type GoogleDocListItem = { @@ -181,7 +182,7 @@ export async function getGoogleDocsConnectionStatus(): Promise<{ export async function listGoogleDocs(query?: string): Promise<{ files: GoogleDocListItem[] }> { const status = await getGoogleDocsConnectionStatus(); if (!status.connected) throw new Error('Google is not connected.'); - if (!status.hasRequiredScopes) throw new Error('Google is missing Drive/Docs scopes. Reconnect Google.'); + if (!status.hasRequiredScopes) throw new Error('Google is missing Drive access. Reconnect Google.'); const driveClient = await getDriveClient(); const clauses = [`mimeType='${GOOGLE_DOC_MIME}'`, 'trashed=false']; @@ -206,7 +207,7 @@ export async function importGoogleDoc(fileId: string, targetFolder: string): Pro }> { const status = await getGoogleDocsConnectionStatus(); if (!status.connected) throw new Error('Google is not connected.'); - if (!status.hasRequiredScopes) throw new Error('Google is missing Drive/Docs scopes. Reconnect Google.'); + if (!status.hasRequiredScopes) throw new Error('Google is missing Drive access. Reconnect Google.'); const doc = await getDocMetadata(fileId); const bytes = await exportDocx(fileId);