mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
Add credential prompting for google service accounts
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user