NISIRA can continuously ingest documents from a designated Google Drive folder without manual uploads. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/HugoX2003/nisira-assistant/llms.txt
Use this file to discover all available pages before exploring further.
GoogleDriveManager class (in rag_system/drive_sync/drive_manager.py) handles authentication, file listing, modification-time-aware downloading, and persistent storage. Once configured, you can trigger syncs on demand through the Admin Panel or let a background polling loop keep the knowledge base up to date automatically.
How the Sync Works
On each sync cycle,sync_documents() calls the Drive API to list all supported files in the configured folder. For each file, it compares the Drive modification time against what is already stored — in PostgreSQL (file_store.get_file_modified_time()) or on the local filesystem. Files that are new or have been updated since the last sync are downloaded to memory and saved to PostgresFileStore (or the local filesystem as a fallback). Files that are already current are skipped.
The polling interval is controlled by GOOGLE_DRIVE_SYNC_INTERVAL (default 300 seconds), read directly from the environment at startup into GOOGLE_DRIVE_CONFIG["sync_interval"].
Supported Formats and Size Limit
| Extension | Max Size |
|---|---|
.pdf | 50 MB |
.txt | 50 MB |
.docx / .doc | 50 MB |
.pptx | 50 MB |
.xlsx | 50 MB |
"TOO_LARGE" sentinel and do not block the sync of other files.
Setup
Create a Google Cloud project and enable the Drive API
In the Google Cloud Console, create a new project (or select an existing one) and enable the Google Drive API from the API Library.
Create credentials
Choose one of two credential types:
- Service Account (recommended for production) — create a service account, download the JSON key file. Share your Drive folder with the service account’s email address (Editor permission) so it has access to the folder contents.
- OAuth 2.0 (development / personal Drive) — create an OAuth 2.0 client ID, download
credentials.json, and complete the browser-based consent flow to generatetoken.json. OAuth tokens use personal Drive quota and avoid the zero-storage limitation of service accounts.
Configure environment variables
Set the following variables before starting the Django server:When
GOOGLE_CREDENTIALS_JSON is set and credentials.json does not yet exist on disk, config.py writes the file automatically from the env var on startup.Verify authentication
NISIRA tries credential methods in this priority order:
- OAuth2 via individual env vars (
GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET,GOOGLE_OAUTH_REFRESH_TOKEN) — uses personal Drive quota. - Existing
token.jsonuser token file. - Service account from
credentials.json.
Drive Management API Endpoints
All endpoints require an admin JWT in theAuthorization: Bearer header.
| Method | Path | Description |
|---|---|---|
GET | /api/admin/drive/files/ | List all files in the configured Drive folder |
POST | /api/admin/drive/upload/ | Upload a local file to the Drive folder |
DELETE | /api/admin/drive/delete/<file_id>/ | Delete a file from Drive by its ID |
POST | /api/admin/drive/sync/ | Trigger a full sync (download new/updated files) |
GET | /api/admin/drive/sync/progress/ | Poll real-time sync progress and log messages |
Management Commands
Run a background polling loop that syncs everyGOOGLE_DRIVE_SYNC_INTERVAL seconds:
Credential Methods in Detail
| Method | When to Use | Token Refresh |
|---|---|---|
OAuth env vars (GOOGLE_OAUTH_CLIENT_ID + GOOGLE_OAUTH_REFRESH_TOKEN) | Production with personal Drive | Automatic via creds.refresh(Request()) |
token.json file | Development | Automatic if refresh_token present; re-run flow if expired |
| Service account JSON | Production with shared folder | No refresh needed; permanent credentials |