Skip to content

Commit bef786c

Browse files
author
Theodore Li
committed
Add credential prompting for google service accounts
1 parent ace8779 commit bef786c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AuthMode, type BlockConfig, isHiddenFromDisplay } from '@/blocks/types'
1010
import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check'
1111
import { PROVIDER_DEFINITIONS } from '@/providers/models'
1212
import { tools as toolsRegistry } from '@/tools/registry'
13+
import { getServiceAccountProviderForProviderId } from '@/lib/oauth/utils'
1314
import { getTrigger, isTriggerValid } from '@/triggers'
1415
import { SYSTEM_SUBBLOCK_IDS } from '@/triggers/constants'
1516

@@ -337,11 +338,25 @@ function transformBlockMetadata(metadata: CopilotBlockMetadata): any {
337338
transformed.authType = metadata.authType
338339

339340
if (metadata.authType === 'OAuth') {
341+
// Resolve the actual OAuth service ID from the oauth-input subblock
342+
const oauthSubBlock = metadata.inputSchema?.find(
343+
(sb: CopilotSubblockMetadata) => sb.type === 'oauth-input' && sb.serviceId
344+
)
345+
const serviceId = oauthSubBlock?.serviceId ?? metadata.id
346+
340347
transformed.requiredCredentials = {
341348
type: 'oauth',
342-
service: metadata.id, // e.g., 'gmail', 'slack', etc.
349+
service: serviceId,
343350
description: `OAuth authentication required for ${metadata.name}`,
344351
}
352+
353+
// Check if this service also supports service account credentials
354+
const serviceAccountProviderId = getServiceAccountProviderForProviderId(serviceId)
355+
if (serviceAccountProviderId) {
356+
transformed.requiredCredentials.serviceAccountType = serviceAccountProviderId
357+
transformed.requiredCredentials.description =
358+
`OAuth or service account authentication supported for ${metadata.name}`
359+
}
345360
} else if (metadata.authType === 'API Key') {
346361
transformed.requiredCredentials = {
347362
type: 'api_key',

0 commit comments

Comments
 (0)