Google Drive Connector
Connect your Google Drive account to upload and process files directly as an external knowledge base. Supports Google Workspace files (Docs, Sheets, Slides), Office files, PDFs, text files, CSVs, images, and more. Authentication is handled via Google OAuth 2.0 with automatic token refresh.
Members connect this service from Settings > Connectors, and one sign-in serves every source that uses it. Admins can check what is still missing in Admin > Connectors. See Connectors.
Setup
Step 1: Create a Google Cloud Project
- Go to the Google Cloud Console and create a new project (or select an existing one)
- Navigate to APIs & Services > Library, then search for and Enable the Google Drive API and the Google Picker API
Step 2: Create OAuth 2.0 Credentials
- Go to APIs & Services > Credentials > Create Credentials > OAuth client ID
- If prompted, configure the OAuth consent screen: Internal for a Google Workspace organization, otherwise External (see the note on verification below), and fill in the required fields
- Select Web application as the application type
- Add the origin you open DocsGPT from to Authorized JavaScript origins, for example
http://localhost:5173for the frontend dev server or the Docker Compose frontend, or the API origin (http://localhost:7091) when the API serves the UI. Google’s file picker runs on that page. - Add your callback URL to Authorized redirect URIs:
- Local:
http://127.0.0.1:7091/api/connectors/callback(the defaultCONNECTOR_REDIRECT_BASE_URI; Admin > Connectors shows the exact value to copy) - Production:
https://yourdomain.com/api/connectors/callback(the value ofCONNECTOR_REDIRECT_BASE_URI, registered as-is)
- Local:
- Click Create and copy the Client ID and Client Secret
Step 3: Configure Environment Variables
Add to your backend .env file:
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Optional: lets members sync whole folders (see below)
GOOGLE_SERVICE_ACCOUNT_KEY=/path/to/service-account-key.json| Variable | Description | Required |
|---|---|---|
GOOGLE_CLIENT_ID | OAuth Client ID from GCP Credentials. Google’s file picker opens with it too | Yes |
GOOGLE_CLIENT_SECRET | OAuth Client Secret from GCP Credentials | Yes |
GOOGLE_DRIVE_ACCESS | file (default): members pick files and folders in Google’s picker. readonly: the sign-in reads the whole Drive. See Picked files or the whole Drive | No |
GOOGLE_SERVICE_ACCOUNT_KEY | A service account’s JSON key, or the path to the key file, for syncing whole folders with GOOGLE_DRIVE_ACCESS=file | No |
VITE_GOOGLE_CLIENT_ID | Frontend .env. Only with GOOGLE_DRIVE_ACCESS=readonly, to use Google’s file picker instead of DocsGPT’s | No |
VITE_GOOGLE_PICKER_API_KEY | API key (APIs & Services > Credentials > Create Credentials > API key) passed to Google’s file picker as its developer key | No |
CONNECTOR_ALLOWED_ORIGINS | Comma-separated frontend origins a sign-in may start from and return to, e.g. https://docsgpt.example.com. Not needed when the frontend is on the origin of CONNECTOR_REDIRECT_BASE_URI or OIDC_FRONTEND_URL, or in local dev when the callback is on localhost/127.0.0.1 and the frontend runs on port 5173 | When the frontend is on its own origin |
If you set VITE_GOOGLE_CLIENT_ID, use the same Client ID as the backend: Google gives DocsGPT access to a picked file only through the project of the client the picker opened with. Publish the OAuth consent screen (or use an internal Workspace app): apps left in Testing get refresh tokens that expire after seven days, which stops background sync.
Step 4: Restart and Use
Restart your application, then go to Settings > Connectors and pick Google Drive. You’ll be redirected to Google to sign in, then can pick files and folders to process.
Picked files or the whole Drive
GOOGLE_DRIVE_ACCESS sets what the sign-in asks Google for:
file (default) | readonly | |
|---|---|---|
| Scope | drive.file | drive.readonly |
| What DocsGPT can read | The files and folders a member picks in Google’s file picker | Everything in the member’s Drive |
| Google’s review of an External app | None for the scope | Verification for restricted scopes, with a yearly security assessment. Until then, members see the unverified-app warning and Google caps the app at 100 users |
| Folder contents | Read through a service account the folder is shared with | Read with the member’s own sign-in |
With file, members always pick in Google’s file picker, opened with GOOGLE_CLIENT_ID. DocsGPT’s own file browser would only list what was picked before. An Internal Workspace app needs no review in either mode, so readonly suits an install used only inside one organization.
A connection keeps the access it signed in with. After switching modes, existing connections work as before until the member reconnects.
Sync whole folders with a service account
With GOOGLE_DRIVE_ACCESS=file, Google gives the sign-in a picked folder but not the files inside it. A service account reads them instead.
Create the service account
In the Google Cloud Console, go to IAM & Admin > Service accounts > Create service account. It needs no roles. Make sure the Google Drive API is enabled in its project.
Add a key
Open the account, go to Keys > Add key > Create new key > JSON, and set GOOGLE_SERVICE_ACCOUNT_KEY to the downloaded file’s path or to its contents. Restart the API and the worker.
Share folders with it
Members pick a folder as before. DocsGPT then shows the service account’s email: share the folder with that address as a Viewer. For a folder in a shared drive, share the folder or add the address to the drive as a Viewer.
How folders stay private:
- DocsGPT reads a folder only after the member’s own sign-in can open it. With
drive.file, that is a folder they picked, so a folder ID alone is not enough. - Inside it, items whose sharing is restricted apart from the folder (limited access) are left out, and so are shortcuts to anything the member cannot open themselves.
- The service account only ever reads. Anything shared with it can be synced by any member who can also open it, so share the folders you mean to sync, not whole drives you don’t.
A folder that is not shared with the service account is skipped and the rest of the source still syncs. Once it is shared, the next sync picks it up. Without GOOGLE_SERVICE_ACCOUNT_KEY, the picker offers files only.
Files, folders and shared drives
- Folders: a selected folder is ingested with everything inside it, the folders inside it included, and keeps its layout. A sync picks up files added to it later. With
GOOGLE_DRIVE_ACCESS=file, this needs the service account. - Shared drives: Google’s file picker has a Shared drives tab, and DocsGPT’s own picker (
GOOGLE_DRIVE_ACCESS=readonly) lists shared drives you are a member of. - Shortcuts: a shortcut is followed to the file or folder it points to, and saved under the shortcut’s name. Something reached twice, such as a shortcut to a folder that is already selected, is read once.
- Names: two files with the same name in one folder are kept apart as
report.pdfandreport_1.pdf. Google Docs, Sheets and Slides are converted to.docx,.xlsxand.pptx. - Skipped files: types DocsGPT cannot read (Forms, Drawings, archives, video) are left out. So are files Google will not export, such as a Google Doc over Google’s 10 MB export limit. One skipped or failed file does not stop the rest of the folder.
Calls to Google are retried, waiting longer after each attempt, when Google rate-limits them or has a temporary error.
Sync
A scheduled sync, or Sync now, first compares each file’s name, location and modified time with the last ingest. When nothing changed, it keeps the existing index and downloads nothing. Otherwise it downloads and indexes the whole selection again. Changing the source’s chunking settings also counts as a change. If a file could not be downloaded last time, the next sync reprocesses the source in full. The exception is a file Google will never export, such as one over the size limit: it does not force a full sync until it is edited.
Troubleshooting
- Google Drive is not offered —
GOOGLE_CLIENT_IDorGOOGLE_CLIENT_SECRETis missing from the backend.env, so the connector stays off. Admin > Connectors lists which one. - Authentication failed — Check that the redirect URI matches exactly and equals
CONNECTOR_REDIRECT_BASE_URI, with no query parameters. Ensure the Google Drive API is enabled. - Sign-in fails with “not an allowed origin” — The frontend runs on an origin the sign-in may not return to. Add it to
CONNECTOR_ALLOWED_ORIGINSin the backend.env. - Permission denied — Verify the OAuth consent screen is configured and the user has access to the target files.
- A folder syncs no files — With
GOOGLE_DRIVE_ACCESS=file, it is not shared with the service account. The worker log names it (“not shared with …”). Share it as a Viewer and sync again. - Folders cannot be selected in the picker —
GOOGLE_SERVICE_ACCOUNT_KEYis not set, or the key cannot be read; the API log says which. - The picker does not open — Enable the Google Picker API in the project of
GOOGLE_CLIENT_ID. - Files not processing — Check backend logs and verify that backend environment variables are correctly set.
For production deployments, add your actual domain to the OAuth consent screen and authorized origins/redirect URIs.