Skip to Content
Docs
Knowledge๐Ÿ”Œ Connectors

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

  1. Go to the Google Cloud Console and create a new project (or select an existing one)
  2. 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

  1. Go to APIs & Services > Credentials > Create Credentials > OAuth client ID
  2. 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
  3. Select Web application as the application type
  4. Add the origin you open DocsGPT from to Authorized JavaScript origins, for example http://localhost:5173 for 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.
  5. Add your callback URL to Authorized redirect URIs:
    • Local: http://127.0.0.1:7091/api/connectors/callback (the default CONNECTOR_REDIRECT_BASE_URI; Admin > Connectors shows the exact value to copy)
    • Production: https://yourdomain.com/api/connectors/callback (the value of CONNECTOR_REDIRECT_BASE_URI, registered as-is)
  6. 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
VariableDescriptionRequired
GOOGLE_CLIENT_IDOAuth Client ID from GCP Credentials. Googleโ€™s file picker opens with it tooYes
GOOGLE_CLIENT_SECRETOAuth Client Secret from GCP CredentialsYes
GOOGLE_DRIVE_ACCESSfile (default): members pick files and folders in Googleโ€™s picker. readonly: the sign-in reads the whole Drive. See Picked files or the whole DriveNo
GOOGLE_SERVICE_ACCOUNT_KEYA service accountโ€™s JSON key, or the path to the key file, for syncing whole folders with GOOGLE_DRIVE_ACCESS=fileNo
VITE_GOOGLE_CLIENT_IDFrontend .env. Only with GOOGLE_DRIVE_ACCESS=readonly, to use Googleโ€™s file picker instead of DocsGPTโ€™sNo
VITE_GOOGLE_PICKER_API_KEYAPI key (APIs & Services > Credentials > Create Credentials > API key) passed to Googleโ€™s file picker as its developer keyNo
CONNECTOR_ALLOWED_ORIGINSComma-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 5173When 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
Scopedrive.filedrive.readonly
What DocsGPT can readThe files and folders a member picks in Googleโ€™s file pickerEverything in the memberโ€™s Drive
Googleโ€™s review of an External appNone for the scopeVerification 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 contentsRead through a service account the folder is shared withRead 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.pdf and report_1.pdf. Google Docs, Sheets and Slides are converted to .docx, .xlsx and .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_ID or GOOGLE_CLIENT_SECRET is 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_ORIGINS in 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_KEY is 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.

Edit this page on GitHub

Last updated on

On this page