Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GoogleDrive_DocumentLoaders implements INode {
name: 'credential',
type: 'credential',
description: 'Google Drive OAuth2 Credential',
credentialNames: ['googleDriveOAuth2']
credentialNames: ['googleDriveOAuth2', 'googleOAuth']
}
this.inputs = [
{
Expand Down Expand Up @@ -205,7 +205,7 @@ class GoogleDrive_DocumentLoaders implements INode {
try {
let credentialData = await getCredentialData(nodeData.credential ?? '', options)
credentialData = await refreshOAuth2Token(nodeData.credential ?? '', credentialData, options)
const accessToken = getCredentialParam('access_token', credentialData, nodeData)
const accessToken = getCredentialParam('access_token', credentialData, nodeData) || credentialData.googleAccessToken

if (!accessToken) {
return returnData
Expand Down Expand Up @@ -297,7 +297,7 @@ class GoogleDrive_DocumentLoaders implements INode {

let credentialData = await getCredentialData(nodeData.credential ?? '', options)
credentialData = await refreshOAuth2Token(nodeData.credential ?? '', credentialData, options)
const accessToken = getCredentialParam('access_token', credentialData, nodeData)
const accessToken = getCredentialParam('access_token', credentialData, nodeData) || credentialData.googleAccessToken

if (!accessToken) {
throw new Error('No access token found in credential')
Expand Down
9 changes: 5 additions & 4 deletions packages/ui/src/views/docstore/LoaderConfigPreviewChunks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ const LoaderConfigPreviewChunks = () => {
if (checkMandatoryFields()) {
setLoading(true)
const config = prepareConfig()
config.loaderId === 'googleDrive' && (config.credential = selectedCredential)
config.previewChunkCount = previewChunkCount

try {
Expand Down Expand Up @@ -214,7 +213,6 @@ const LoaderConfigPreviewChunks = () => {
if (checkMandatoryFields()) {
setLoading(true)
const config = prepareConfig()
config.loaderId === 'googleDrive' && (config.credential = selectedCredential)
try {
const saveResp = await documentStoreApi.saveProcessingLoader(config)
setLoading(false)
Expand Down Expand Up @@ -290,8 +288,10 @@ const LoaderConfigPreviewChunks = () => {
if (textSplitter) config.splitterName = textSplitter.label
}

if (selectedDocumentLoader.credential) {
config.credential = selectedDocumentLoader.credential
// Use credential from state, or fall back to inputs.credential (set when user selects in UI)
const credentialId = selectedDocumentLoader.credential || selectedDocumentLoader.inputs?.credential
if (credentialId) {
config.credential = credentialId
}

return config
Expand All @@ -314,6 +314,7 @@ const LoaderConfigPreviewChunks = () => {
// If this is a document store edit config, set the existing input values
if (existingLoaderFromDocStoreTable && existingLoaderFromDocStoreTable.loaderConfig) {
nodeData.inputs = existingLoaderFromDocStoreTable.loaderConfig
nodeData.credential = existingLoaderFromDocStoreTable.credential
setLoaderName(existingLoaderFromDocStoreTable.loaderName)
}
setSelectedDocumentLoader(nodeData)
Expand Down