MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / buildGoogleCredentials

Function buildGoogleCredentials

packages/components/src/google-utils.ts:6–29  ·  view source on GitHub ↗
(nodeData: INodeData, options: ICommonObject)

Source from the content-addressed store, hash-verified

4type SupportedAuthOptions = ChatVertexAIInput['authOptions'] | VertexAIInput['authOptions']
5
6export const buildGoogleCredentials = async (nodeData: INodeData, options: ICommonObject): Promise<SupportedAuthOptions | null> => {
7 const credentialData = await getCredentialData(nodeData.credential ?? '', options)
8 const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
9 const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
10 const projectID = getCredentialParam('projectID', credentialData, nodeData)
11
12 const authOptions: any = {}
13 if (Object.keys(credentialData).length !== 0) {
14 if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
15 throw new Error('Please specify your Google Application Credential')
16 if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
17 throw new Error(
18 'Error: More than one component has been inputted. Please use only one of the following: Google Application Credential File Path or Google Credential JSON Object'
19 )
20
21 if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
22 else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
23 authOptions.credentials = JSON.parse(googleApplicationCredential)
24
25 if (projectID) authOptions.projectId = projectID
26 }
27
28 return authOptions
29}

Callers 3

initMethod · 0.90
initMethod · 0.90
initMethod · 0.90

Calls 3

getCredentialDataFunction · 0.85
getCredentialParamFunction · 0.85
parseMethod · 0.65

Tested by

no test coverage detected