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, lists the selection from Drive without downloading it and compares each file, by its ID and modified time, with what the last sync indexed. Only new and edited files are downloaded and embedded. A renamed or moved file keeps its chunks, which take its new path and link. A file that left the selection loses its chunks. When nothing changed, nothing is downloaded.
A file that could not be downloaded or read is recorded, and the source says how many there are, with Try again now. A new file stays out of the index until it can be read; an edited file usually keeps its earlier content in the index, so search can still return the older version. Later syncs try only those files again. A failure that can pass, such as a rate limit, a timeout or a sharing change, is tried until it has failed three times in all for that version of the file, then again once the file is edited. A file DocsGPT can never read as it is, such as a Google Doc over the export limit or a corrupt file, waits for its next edit or for a change of the OCR or parser settings. Try again now retries every recorded file at once.
Changing the sourceโs chunking settings makes the next sync process the whole selection once. So does a sourceโs first sync after an upgrade from a version without this record. Changing its retrieval settings doesnโt: they apply on the next question. While a sync processes the whole selection, the source keeps answering from its previous index on pgvector; see What a sync re-embeds.
Team accounts
In a team workspace, an Admin can connect a Google Drive account for the team; see Team connections. Only the Admin who connected it picks files and folders from it, and the teamโs sources read Drive with that account.
If another Admin later chooses Reconnect and signs in with their own Google account, the sources stay, but each sync reads Drive as the new account. Files and folders the new account canโt open drop out of the sources at the next sync. With GOOGLE_DRIVE_ACCESS=file (the default), Google lets DocsGPT open only what the signed-in account picked, so most of what the previous Admin picked drops out: the new Admin picks it again from each source. With readonly, only what the new account has no access to in Drive drops out.
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.
Last updated on
๐ Connectors Overview
Connect DocsGPT to the services your team uses. One connection can sync content into Knowledge and give agents tools, with credentials encrypted on the server.
๐ SharePoint / OneDrive
Connect your Microsoft SharePoint or OneDrive as an external knowledge base to upload and process files directly.