Add credential prompting for google service accounts

This commit is contained in:
Theodore Li
2026-04-04 17:21:14 -07:00
parent ace87791d8
commit bef786cd5b

View File

@@ -10,6 +10,7 @@ import { AuthMode, type BlockConfig, isHiddenFromDisplay } from '@/blocks/types'
import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check'
import { PROVIDER_DEFINITIONS } from '@/providers/models'
import { tools as toolsRegistry } from '@/tools/registry'
import { getServiceAccountProviderForProviderId } from '@/lib/oauth/utils'
import { getTrigger, isTriggerValid } from '@/triggers'
import { SYSTEM_SUBBLOCK_IDS } from '@/triggers/constants'
@@ -337,11 +338,25 @@ function transformBlockMetadata(metadata: CopilotBlockMetadata): any {
transformed.authType = metadata.authType
if (metadata.authType === 'OAuth') {
// Resolve the actual OAuth service ID from the oauth-input subblock
const oauthSubBlock = metadata.inputSchema?.find(
(sb: CopilotSubblockMetadata) => sb.type === 'oauth-input' && sb.serviceId
)
const serviceId = oauthSubBlock?.serviceId ?? metadata.id
transformed.requiredCredentials = {
type: 'oauth',
service: metadata.id, // e.g., 'gmail', 'slack', etc.
service: serviceId,
description: `OAuth authentication required for ${metadata.name}`,
}
// Check if this service also supports service account credentials
const serviceAccountProviderId = getServiceAccountProviderForProviderId(serviceId)
if (serviceAccountProviderId) {
transformed.requiredCredentials.serviceAccountType = serviceAccountProviderId
transformed.requiredCredentials.description =
`OAuth or service account authentication supported for ${metadata.name}`
}
} else if (metadata.authType === 'API Key') {
transformed.requiredCredentials = {
type: 'api_key',