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#
Secure Google account authentication
Sync entire folders and subfolders
Support for Docs, Sheets, PDFs, and more
Automatic periodic synchronization
Prerequisites#
Before using Google Drive connector, you need:
- Google Cloud Project with Drive API enabled
- OAuth2 Credentials (Client ID and Secret)
- Configured Redirect URI
Setup#
Step 1: Create Google Cloud Project#
- Go to Google Cloud Console
- Create a new project or select existing
- Enable the Google Drive API
Step 2: Create OAuth Credentials#
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Select Web application
- Add authorized redirect URI:
http://localhost:3000/api/google-services/oauth2callback - 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:
- Sign in to their Google account
- Grant access to Google Drive
- 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#
| Option | Type | Default | Description |
|---|---|---|---|
folderId | String | Required | Google Drive folder ID |
includeSubfolders | Boolean | true | Include files from subfolders |
fileTypes | Array | All | MIME types to include |
maxFiles | Integer | 1000 | Maximum files per sync |
Supported File Types#
| Google Format | Exported As |
|---|---|
| Google Docs | |
| Google Sheets | XLSX |
| Google Slides | |
| Native PDF | PDF (direct) |
| Word Documents | |
| Images | PNG/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#
| Error | Cause | Solution |
|---|---|---|
AUTH_EXPIRED | OAuth token expired | Re-authenticate via auth flow |
FOLDER_NOT_FOUND | Invalid folder ID | Verify folder ID and permissions |
QUOTA_EXCEEDED | Google API rate limit | Reduce sync frequency |
ACCESS_DENIED | Insufficient permissions | Check 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.