From 517f1a91b662181de25e4f803880edc69e35b576 Mon Sep 17 00:00:00 2001 From: Adam Gough <77861281+aadamgough@users.noreply.github.com> Date: Sat, 25 Oct 2025 09:08:49 -1000 Subject: [PATCH] fix(google-scopes): added forms and different drive scope (#1532) * added google forms scope and google drive scope * added back file scope --------- Co-authored-by: Adam Gough Co-authored-by: Adam Gough --- .../components/oauth-required-modal.tsx | 2 ++ apps/sim/blocks/blocks/google_docs.ts | 5 ++++- apps/sim/blocks/blocks/google_drive.ts | 20 +++++++++++++++---- apps/sim/lib/auth.ts | 3 +++ apps/sim/lib/oauth/oauth.ts | 15 +++++++++++--- apps/sim/tools/google_docs/create.ts | 5 ++++- apps/sim/tools/google_docs/read.ts | 5 ++++- apps/sim/tools/google_docs/write.ts | 5 ++++- apps/sim/tools/google_drive/create_folder.ts | 5 ++++- apps/sim/tools/google_drive/get_content.ts | 5 ++++- apps/sim/tools/google_drive/list.ts | 5 ++++- apps/sim/tools/google_drive/upload.ts | 5 ++++- 12 files changed, 65 insertions(+), 15 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx index 19d1dd67fb..0877612530 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/credential-selector/components/oauth-required-modal.tsx @@ -38,11 +38,13 @@ const SCOPE_DESCRIPTIONS: Record = { 'https://www.googleapis.com/auth/gmail.modify': 'View and manage your email messages', // 'https://www.googleapis.com/auth/gmail.readonly': 'View and read your email messages', // 'https://www.googleapis.com/auth/drive': 'View and manage your Google Drive files', + 'https://www.googleapis.com/auth/drive.readonly': 'View and read your Google Drive files', 'https://www.googleapis.com/auth/drive.file': 'View and manage your Google Drive files', // 'https://www.googleapis.com/auth/documents': 'View and manage your Google Docs', 'https://www.googleapis.com/auth/calendar': 'View and manage your calendar', 'https://www.googleapis.com/auth/userinfo.email': 'View your email address', 'https://www.googleapis.com/auth/userinfo.profile': 'View your basic profile info', + 'https://www.googleapis.com/auth/forms.responses.readonly': 'View responses to your Google Forms', 'read:page:confluence': 'Read Confluence pages', 'write:page:confluence': 'Write Confluence pages', 'read:me': 'Read your profile information', diff --git a/apps/sim/blocks/blocks/google_docs.ts b/apps/sim/blocks/blocks/google_docs.ts index ca7ec792ab..3b83b3ab85 100644 --- a/apps/sim/blocks/blocks/google_docs.ts +++ b/apps/sim/blocks/blocks/google_docs.ts @@ -37,7 +37,10 @@ export const GoogleDocsBlock: BlockConfig = { required: true, provider: 'google-docs', serviceId: 'google-docs', - requiredScopes: ['https://www.googleapis.com/auth/drive.file'], + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], placeholder: 'Select Google account', }, // Document selector (basic mode) diff --git a/apps/sim/blocks/blocks/google_drive.ts b/apps/sim/blocks/blocks/google_drive.ts index f8b30c7b6b..60a6f9708f 100644 --- a/apps/sim/blocks/blocks/google_drive.ts +++ b/apps/sim/blocks/blocks/google_drive.ts @@ -37,7 +37,10 @@ export const GoogleDriveBlock: BlockConfig = { required: true, provider: 'google-drive', serviceId: 'google-drive', - requiredScopes: ['https://www.googleapis.com/auth/drive.file'], + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], placeholder: 'Select Google Drive account', }, // Create/Upload File Fields @@ -110,7 +113,10 @@ export const GoogleDriveBlock: BlockConfig = { canonicalParamId: 'folderId', provider: 'google-drive', serviceId: 'google-drive', - requiredScopes: ['https://www.googleapis.com/auth/drive.file'], + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], mimeType: 'application/vnd.google-apps.folder', placeholder: 'Select a parent folder', mode: 'basic', @@ -186,7 +192,10 @@ export const GoogleDriveBlock: BlockConfig = { canonicalParamId: 'folderId', provider: 'google-drive', serviceId: 'google-drive', - requiredScopes: ['https://www.googleapis.com/auth/drive.file'], + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], mimeType: 'application/vnd.google-apps.folder', placeholder: 'Select a parent folder', mode: 'basic', @@ -213,7 +222,10 @@ export const GoogleDriveBlock: BlockConfig = { canonicalParamId: 'folderId', provider: 'google-drive', serviceId: 'google-drive', - requiredScopes: ['https://www.googleapis.com/auth/drive.file'], + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], mimeType: 'application/vnd.google-apps.folder', placeholder: 'Select a folder to list files from', mode: 'basic', diff --git a/apps/sim/lib/auth.ts b/apps/sim/lib/auth.ts index 1bc7bc06b9..94f085a99e 100644 --- a/apps/sim/lib/auth.ts +++ b/apps/sim/lib/auth.ts @@ -426,6 +426,7 @@ export const auth = betterAuth({ scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', + 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.file', ], prompt: 'consent', @@ -440,6 +441,7 @@ export const auth = betterAuth({ scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', + 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.file', ], prompt: 'consent', @@ -454,6 +456,7 @@ export const auth = betterAuth({ scopes: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', + 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.file', ], prompt: 'consent', diff --git a/apps/sim/lib/oauth/oauth.ts b/apps/sim/lib/oauth/oauth.ts index 7dec2068e3..b7fa4240a4 100644 --- a/apps/sim/lib/oauth/oauth.ts +++ b/apps/sim/lib/oauth/oauth.ts @@ -124,7 +124,10 @@ export const OAUTH_PROVIDERS: Record = { providerId: 'google-drive', icon: (props) => GoogleDriveIcon(props), baseProviderIcon: (props) => GoogleIcon(props), - scopes: ['https://www.googleapis.com/auth/drive.file'], + scopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], }, 'google-docs': { id: 'google-docs', @@ -133,7 +136,10 @@ export const OAUTH_PROVIDERS: Record = { providerId: 'google-docs', icon: (props) => GoogleDocsIcon(props), baseProviderIcon: (props) => GoogleIcon(props), - scopes: ['https://www.googleapis.com/auth/drive.file'], + scopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], }, 'google-sheets': { id: 'google-sheets', @@ -142,7 +148,10 @@ export const OAUTH_PROVIDERS: Record = { providerId: 'google-sheets', icon: (props) => GoogleSheetsIcon(props), baseProviderIcon: (props) => GoogleIcon(props), - scopes: ['https://www.googleapis.com/auth/drive.file'], + scopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], }, 'google-forms': { id: 'google-forms', diff --git a/apps/sim/tools/google_docs/create.ts b/apps/sim/tools/google_docs/create.ts index 4f025f4d79..3a21a715af 100644 --- a/apps/sim/tools/google_docs/create.ts +++ b/apps/sim/tools/google_docs/create.ts @@ -13,7 +13,10 @@ export const createTool: ToolConfig oauth: { required: true, provider: 'google-docs', - additionalScopes: ['https://www.googleapis.com/auth/drive.file'], + additionalScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], }, params: { diff --git a/apps/sim/tools/google_docs/write.ts b/apps/sim/tools/google_docs/write.ts index 51b5bcb34a..a82b6b4648 100644 --- a/apps/sim/tools/google_docs/write.ts +++ b/apps/sim/tools/google_docs/write.ts @@ -9,7 +9,10 @@ export const writeTool: ToolConfig