@@ -10,6 +10,7 @@ import { AuthMode, type BlockConfig, isHiddenFromDisplay } from '@/blocks/types'
1010import { getUserPermissionConfig } from '@/ee/access-control/utils/permission-check'
1111import { PROVIDER_DEFINITIONS } from '@/providers/models'
1212import { tools as toolsRegistry } from '@/tools/registry'
13+ import { getServiceAccountProviderForProviderId } from '@/lib/oauth/utils'
1314import { getTrigger , isTriggerValid } from '@/triggers'
1415import { 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