IngestIQ

Google Drive

Sync documents from Google Drive

Overview#

The Google Drive connector allows you to ingest documents directly from Google Drive folders using OAuth2 authentication.

Features#

OAuth2 Authentication

Secure Google account authentication

Folder Sync

Sync entire folders and subfolders

Multiple Formats

Support for Docs, Sheets, PDFs, and more

Scheduled Sync

Automatic periodic synchronization

Prerequisites#

Before using Google Drive connector, you need:

  1. Google Cloud Project with Drive API enabled
  2. OAuth2 Credentials (Client ID and Secret)
  3. Configured Redirect URI

Setup#

Step 1: Create Google Cloud Project#

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable the Google Drive API

Step 2: Create OAuth Credentials#

  1. Go to APIs & Services → Credentials
  2. Click Create Credentials → OAuth client ID
  3. Select Web application
  4. Add authorized redirect URI:
    http://localhost:3000/api/google-services/oauth2callback
    
  5. Save your Client ID and Client Secret

Step 3: Configure Environment#

Add to your .env file:

GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/api/google-services/oauth2callback

OAuth Flow#

1. Get Authorization URL#

curl http://localhost:3000/api/google-services/auth-url \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response:

{
  "authUrl": "https://accounts.google.com/o/oauth2/v2/auth?..."
}

2. User Authorization#

Redirect the user to the authUrl. They will:

  1. Sign in to their Google account
  2. Grant access to Google Drive
  3. Be redirected back with an authorization code

3. Handle Callback#

The callback is handled automatically at /api/google-services/oauth2callback.

Configuration#

Google Drive Config#

{
  "folderId": "1A2B3C4D5E6F7G8H9I0J",
  "includeSubfolders": true,
  "fileTypes": ["application/pdf", "application/vnd.google-apps.document"],
  "maxFiles": 500
}

Configuration Options#

OptionTypeDefaultDescription
folderIdStringRequiredGoogle Drive folder ID
includeSubfoldersBooleantrueInclude files from subfolders
fileTypesArrayAllMIME types to include
maxFilesInteger1000Maximum files per sync

Supported File Types#

Google FormatExported As
Google DocsPDF
Google SheetsXLSX
Google SlidesPDF
Native PDFPDF (direct)
Word DocumentsPDF
ImagesPNG/JPEG

Google Workspace files (Docs, Sheets, Slides) are automatically exported to compatible formats.

Finding the Folder ID#

The folder ID is in the Google Drive URL:

https://drive.google.com/drive/folders/1A2B3C4D5E6F7G8H9I0J
                                        ^^^^^^^^^^^^^^^^^^^^^^
                                        This is the folder ID

Creating Google Drive Config#

curl -X POST http://localhost:3000/api/v2/connector-configs \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Engineering Docs Folder",
    "connectorTypeId": 3,
    "config": {
      "folderId": "1A2B3C4D5E6F7G8H9I0J",
      "includeSubfolders": true
    }
  }'

Executing a Sync#

curl -X POST http://localhost:3000/api/v2/knowledgebases/{kbId}/pipelines/{pipelineId}/execute \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Scheduling Sync#

Keep your Knowledge Base updated with scheduled syncs:

{
  "scheduleConfig": {
    "enable_automation": true,
    "interval_type": "Daily",
    "interval_time": "06:00",
    "timezone": "UTC"
  }
}

Best Practices#

Create a specific folder in Google Drive for documents you want to ingest, rather than syncing your entire drive.

Map different folders to different Knowledge Bases:

  • /IngestIQ/Engineering → Engineering KB
  • /IngestIQ/Marketing → Marketing KB

Ensure the authenticated Google account has read access to all folders you want to sync.

Error Handling#

ErrorCauseSolution
AUTH_EXPIREDOAuth token expiredRe-authenticate via auth flow
FOLDER_NOT_FOUNDInvalid folder IDVerify folder ID and permissions
QUOTA_EXCEEDEDGoogle API rate limitReduce sync frequency
ACCESS_DENIEDInsufficient permissionsCheck folder sharing settings

Token Management#

OAuth tokens are stored securely and refreshed automatically. If you need to re-authenticate:

curl -X DELETE http://localhost:3000/api/google-services/disconnect \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Then repeat the OAuth flow.

Documentation