Skip to main content

Context7 can sync Google Docs and Google Slides from Google Drive and serve them like any other library. Google Drive stays the source of truth: a daily sync picks up edits, and files that are removed or no longer shared leave the results.

An admin connects Google once under Workspace Settings › Google. Then an admin chooses which folders, Shared Drives, Docs and presentations to sync from Add source → Google Drive, Google Docs or Google Slides. All three use the same connection. Only the selected items, and the Docs and presentations under selected folders, are indexed.

Note

Google Docs and Google Slides are supported. Spreadsheets, PDFs and other file types in a selected folder are skipped. The picker marks them as not supported.

Choose a connection method#

Context7 reads Drive as one Google identity, and sees only what that identity can open. It always uses one read-only scope:

ScopeWhy
https://www.googleapis.com/auth/drive.readonlyList the selected folders, export Google Docs and read Google Slides. Context7 never writes to Drive.

There are three ways to give Context7 that identity:

MethodIdentity Google seesNeedsGood fit when
Google accountA dedicated Workspace user, such as context7-bot@yourcompany.comAn internal OAuth client, and one sign-in by an adminYour organization blocks service account keys or sharing outside your domain
Service account keyA service account, or a Workspace user through domain-wide delegationA JSON key for the service accountYour organization allows service account keys
Server credentialsA service account, through the server’s own credentialsContext7 on GKE with Workload Identity, or workload identity federation from AWS, Azure or another OIDC providerYou do not want any key or token stored in Context7
Tip

If your security team blocks service account keys and sharing outside your domain, use Google account. It needs no key and no domain-wide delegation, and nothing is shared outside your organization.

Open Workspace Settings › Google and choose the method under Authentication. Each method has a Set up Google Cloud panel with the steps below. Enter your project ID there, and the panel fills it into the commands.

Google account#

Context7 signs in as a Workspace user that exists only for Context7. You share folders with that user like with any colleague.

Enable the Drive and Slides APIs

In the Google Cloud console, select a project that belongs to your Workspace organization. Open APIs & Services → Library and enable the Google Drive API and the Google Slides API, or run:

Configure the consent screen as Internal

Open Google Auth Platform and click Get started. Enter an app name such as “Context7”, and under Audience choose Internal. Only users of your organization can sign in, and Google does not need to verify the app.

Create an OAuth client

Open Clients, click Create client, and choose a client type:

  • Web application: Under Authorized redirect URIs, add the redirect URI that the settings page shows, for example https://context7.yourcompany.com/api/google/oauth/callback. After the sign-in, Google sends the browser back to Context7. Google accepts only an HTTPS URI with a domain under a public top-level domain, so this does not work for an IP address or a name such as context7.corp. The host can still be reachable only from your network.
  • Desktop app: Use this when Context7 has no such address. The client needs no redirect URI. After the sign-in, Google opens an address on 127.0.0.1 that does not load. You copy that address from the browser’s address bar and paste it into Address after sign-in.

Copy the client ID and the client secret into OAuth client ID and OAuth client secret.

Create a Workspace user for Context7

In the Google Admin console, add a user only for Context7, such as context7-bot@yourcompany.com. Like any Workspace user, it usually takes a paid license seat. Do not use a person’s account: Context7 can read everything this account can open, and the connection stops if the account is suspended or deleted.

Share your folders with that user

In Google Drive, share each folder with the Context7 user with Viewer access, or add the user to each Shared Drive as a Viewer.

Sign in as that user

Click Sign in with Google and sign in as the Context7 user, not as yourself. On Google’s account list, choose Use another account. If Google says the app is blocked, a Workspace admin turns on Trust internal, domain-owned apps in Security → API controls.

Context7 stores the client secret and the sign-in’s refresh token encrypted, and never returns them from any API. If Google later refuses the sign-in, for example because the account was suspended or its sessions were revoked, the settings page shows Reconnect required and syncs fail until an admin clicks Reconnect and signs in again.

Service account key#

Context7 signs in as a service account with a JSON key.

Create the service account and its key

Run these commands in Cloud Shell or with the gcloud CLI. Replace PROJECT_ID with your project ID. The first command enables the Google Drive API and the Google Slides API. The service account needs no IAM roles in the project.

Organizations created on or after May 3, 2024 block service account keys by default with the iam.disableServiceAccountKeyCreation policy. If Google refuses to create the key, ask an organization admin to allow keys for this project, or use another method.

Paste the key

Paste the contents of context7-drive-key.json into Service account JSON key, then delete the file. Click Test connection, then click Connect.

Context7 checks the key with Google before it saves it, stores it encrypted, and never returns it from any API. The settings page shows only the service account’s email and the last characters of the key ID. To rotate the key, paste the new key and save.

Share the content

In Google Drive, share each folder you want to sync with the service account’s email address, with Viewer access. For a Shared Drive, add the service account as a member with the Viewer role. The email ends in iam.gserviceaccount.com, so if Drive does not allow sharing outside your organization, ask a Workspace admin to allow it for the service account, or use domain-wide delegation.

Domain-wide delegation (optional)#

If sharing with the service account is not practical, the service account can act as one Workspace user and see what that user sees. You then share folders with that user, so nothing is shared outside your domain.

  1. Copy the service account’s client ID. It is client_id in the JSON key, and the Set up Google Cloud panel shows it after you paste the key.
  2. A Workspace super admin opens Domain-wide delegation in the Google Admin console (Security → Access and data control → API controls) and clicks Add new.
  3. They enter that client ID and the scope https://www.googleapis.com/auth/drive.readonly.
  4. In Context7, enter the user’s email address in Act as user.
Warning

Context7 acts only as the user in Act as user. But Google lets a service account with domain-wide delegation read Drive as any user in your domain, within the allowed scope. Protect the key accordingly, and expect your security team to review this setup.

Note

Without delegation, the service account can read only what is explicitly shared with it. This keeps the approved content small and visible in Drive’s sharing settings, so prefer it when you can.

Server credentials#

Context7 uses the server’s Application Default Credentials, so no key is stored in Context7:

Create the service account as for a key, without the key command. For workload identity federation, let your workload identity pool act as the service account, and write the credential file. Replace the uppercase values with your pool, provider, subject and token file. On AWS or Azure, use --aws or --azure instead of --credential-source-file:

Set GOOGLE_APPLICATION_CREDENTIALS to the path of google-credentials.json on the Context7 server, and restart it. Then share your folders with the service account as for a key, click Test connection, and click Connect.

Domain-wide delegation is not available in this mode.

Test the connection#

Test connection checks the credentials with Google and lists the first folders, files and Shared Drives that the identity can see. If the list is empty, share a folder with the identity, then test again. After you connect, the page shows the identity’s email with a copy button.

Add a library#

Go to Add and choose a Google source:

  • Google Drive syncs folders, Shared Drives, Docs and presentations.
  • Google Docs and Google Slides sync single files of that kind. Folders and Shared Drives stay browsable but cannot be selected.

The picker is a tree of your Shared Drives and the items shared with the Context7 identity:

  • Click a folder or Shared Drive to open it. Its contents load when you open it, and long lists load more as you scroll.
  • Type in the search box to find folders and files by name in all of Drive, also inside folders that you have not opened.
  • Check a folder or Shared Drive to select all of it. Later syncs then also pick up new files in it. If you uncheck items inside it, only its checked items are selected.
  • Selected shows what the library will contain. A library can have up to 200 selected items.

Enter a title and click Start sync. The description is optional. The selection defines the library: to sync a different set of folders, add another library.

Each Doc is indexed under its Google URL, for example https://docs.google.com/document/d/<id>/edit. That link is the Source: of every result, so an agent can point people to the original document. Results taken from a document’s text also name it, as Source: <Doc title> (<link>).

Google Slides#

Each slide of a presentation is indexed as its own page, with a link that opens that slide: https://docs.google.com/presentation/d/<id>/edit#slide=id.<slide id>. The slide’s title becomes its heading, and its text, lists, links, tables and speaker notes follow. Results taken from a slide name the deck and the slide, as Source: <deck name>, slide <n>: <slide title> (<link>). Hidden (skipped) slides are not indexed.

Elements are indexed in reading order: top to bottom, and left to right within a row. An image, chart or video contributes its alt text, as *Image: …*, *Chart: …* or *Video: …*, and a video that has one keeps its link. WordArt contributes its text. Auto-generated alt text, such as a file name or “Picture 3”, is left out. Images, charts, diagrams and videos themselves are not indexed.

Docs index an image’s alt text the same way, as *Image: …*.

When a presentation changes, Context7 reads the whole presentation again:

  • A slide that did not change reuses its last extraction.
  • A deleted slide leaves the results.
  • If one slide fails to index, its last indexed version stays.
  • If the presentation cannot be read, all its slides keep their last indexed version.
  • A presentation with no visible slides counts as empty and leaves the results.

How syncing works#

Every sync lists the selected folders again and compares each file with the last sync:

Change in DriveWhat happens
A file was edited, renamed or moved inside the selectionIt is read and indexed again.
A file did not changeIts indexed content is kept as it is. No LLM or embedding calls are made for it.
A file was deleted, trashed, moved out of the selection, or unsharedIt leaves the results.
A selected folder or Shared Drive was deleted, trashed, or unsharedAll its files leave the results, and the library page and the Libraries list in Workspace Settings › Google show a warning. Share it again to restore them.
A file was emptied, or has nothing to indexIt leaves the results. It is checked again when it changes.
A new file appeared in a selected folderIt is indexed.

A sync builds the new index next to the live one and swaps it in only when it finishes, so queries always see a complete library.

Failures keep valid content#

  • One file fails (for example a Doc is larger than Drive’s 10 MB export limit, or the LLM times out while extracting it): the last indexed version of that file stays in the results. The library page shows a warning, its logs list the file and the reason, the Libraries list in Workspace Settings › Google shows the failed files, and the next sync tries it again.
  • The whole sync fails (for example Google refuses access because the Drive API is disabled, or Google cannot be reached): all live content stays as it was, and the error is shown in the library’s logs.
Warning

Sharing is the approval. When a selected folder or Shared Drive is no longer shared with the Context7 identity, the next sync removes its files from the results. Check sharing changes before the daily sync if you want to keep the content.

Context7 retries Google API quota errors with exponential backoff and limits how many requests it sends at once.

Scheduled sync#

Google Drive libraries sync every day at 03:00 server time by default. Under Sync schedule on the Google page (Workspace Settings › Google), you can:

  • turn the scheduled sync off,
  • change the schedule: pick a preset such as Every 6 hours, or enter a cron expression such as 0 */6 * * *,
  • click Sync all now to queue every Google Drive library at once.

When a sync fails, scheduled or manual, Context7 retries that library after 15 minutes, 1 hour and 6 hours. Each delay counts from the previous attempt. To sync one library by hand, click Refresh on its page, or Sync now next to it in the Libraries list. To read and re-index every file instead of skipping unchanged ones, select Re-index all files in the Refresh dialog, or in the library’s menu in the Libraries list.

Only an admin can refresh a Google Drive library, even when Refresh repositories is on in Workspace Settings › Authorization: the sync reads Drive with the connector’s credentials.

Monitor libraries#

The Libraries list on the Google page (Workspace Settings › Google) shows every Google Drive library with its selection, its last sync, and a status:

StatusMeaning
SyncedThe last sync finished with no failed files.
Syncing or QueuedA sync is running or waiting in the parse queue.
N files failedSome files could not be refreshed. Expand the row to see each file and the reason; their last indexed version is still served.
Folder unavailableA selected folder or Shared Drive is no longer shared with the Context7 identity, and its files were removed.
Sync failedThe whole sync failed, so the library still serves its previous content. Expand the row for the error.

Expanding a row shows the most common failure reasons and up to 50 failed files, each linked to Drive. Download CSV exports every failed file. Problem libraries sort to the top, and Needs attention filters the list to them.

Authority labels#

Authority labels can match Google Drive content by path or by URL:

  • A path pattern matches the file’s folder path and file name inside the selection. For example, /QA/Standards/Release sign-off is the Release sign-off Doc in the Standards folder of a selected QA folder, and the prefix /QA/Standards/ matches every file in that folder. For a Shared Drive, the path starts with the Shared Drive’s name.
  • A URL pattern matches the Doc’s Google URL, for example https://docs.google.com/document/d/<id>.

For a presentation:

  • A URL prefix https://docs.google.com/presentation/d/<id> matches every slide of that presentation.
  • A path rule matches the presentation’s path in Drive, for example /QA/Standards/Release review for the Release review presentation in the Standards folder, and applies to all its slides.

Network access#

The server talks only to Google:

HostUsed for
oauth2.googleapis.comAccess tokens for a service account key or a Google account
sts.googleapis.comAccess tokens for workload identity federation
iamcredentials.googleapis.comAccess tokens for workload identity federation with service account impersonation
www.googleapis.comThe Drive API
slides.googleapis.comThe Slides API, for presentations

Set GOOGLE_DRIVE_API_URL and GOOGLE_SLIDES_API_URL to send Drive and Slides API calls through another endpoint, such as a Private Google Access address or a proxy. Each value must include the API path, for example https://www.googleapis.com/drive/v3 and https://slides.googleapis.com/v1.

With Google account, the admin’s browser also opens accounts.google.com for the sign-in. To send the server’s OAuth calls through another endpoint, set GOOGLE_OAUTH_TOKEN_URL (default https://oauth2.googleapis.com/token), GOOGLE_OAUTH_REVOKE_URL (default https://oauth2.googleapis.com/revoke) and GOOGLE_OAUTH_AUTHORIZE_URL (default https://accounts.google.com/o/oauth2/v2/auth).

Troubleshooting#

MessageFix
”The private_key in the JSON key is damaged”The key was cut or changed when it was copied. Paste the whole JSON file again, or create a new key.
”Nothing is shared with … yet”The credentials work, but no folder or Shared Drive is shared with the Context7 identity. Share one with Viewer access, then test again.
”Google rejected the credentials”Check the key. With delegation, check that the client ID is allowed the drive.readonly scope in the Admin console.
”Google denied access … Check that the Drive API is enabled”Enable the Google Drive API in the Google Cloud project you connected.
”Google Slides API request failed (403 …)”Enable the Google Slides API in the Google Cloud project you connected.
”No longer available to the Google connector: folder …”The folder was deleted, trashed or unshared, and its files were removed. Share it with the Context7 identity again, then click Refresh.
”Google refused access to the selected folder …”Check that the Drive API is enabled and that the connector can read the folder. Live content is kept until this is fixed.
”The document is larger than the 10 MB Google Drive export limit”Split the document. Its last indexed version stays available.
”The selection has more than 10000 documents”A library holds at most 10,000 Docs and presentations. Split the selection into several libraries, or raise the limit with the GOOGLE_DRIVE_MAX_FILES environment variable.
”Google no longer accepts the sign-in for … (invalid_grant)“The Google account was suspended, its password policy ended the session, or the access was revoked. Click Reconnect on the Google page and sign in as the Context7 user again.
Google says the app is blocked when you sign inA Workspace admin turns on Trust internal, domain-owned apps in Security → API controls.
”redirect_uri_mismatch” when signing inThe redirect URI in the Web application client does not match the one the settings page shows. Copy it again, or use a Desktop app client.
”The Google connector was replaced by a different account”The library was added with another service account, delegated user or Google account. Add the library again with the current connection.