Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

GoogleDriveFetcher

Fetch the full content of Google Drive files via the Drive API v3. Use this component with GoogleDriveRetriever to download file content after search, or pass file IDs and URLs directly.

Key Features

  • Downloads binary files (PDF, DOCX, images, and others) as ByteStream objects.
  • Exports native Google Docs, Sheets, and Slides to Office formats by default (DOCX, XLSX, PPTX).
  • Accepts Document objects from GoogleDriveRetriever or raw file IDs and Drive URLs.
  • Skips folders and non-downloadable Google file types.
  • Supports concurrent fetching in async mode.

Configuration

Add Workspace-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Workspace>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in the current workspace.

Add Organization-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Organization>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
  1. Drag the GoogleDriveFetcher component onto the canvas from the Component Library.
  2. Wire an upstream OAuthTokenResolver to provide a delegated Google OAuth bearer token on the access_token input.
  3. Connect GoogleDriveRetriever.documents or file IDs and URLs to the targets input.
  4. Connect the streams output to downstream converters such as PyPDFToDocument or DOCXToDocument.

The access token must carry a scope that allows reading file content, for example https://www.googleapis.com/auth/drive.readonly.

Connections

GoogleDriveFetcher receives an access_token and a list of targets (Document objects or file ID/URL strings). It outputs streams as a list of ByteStream objects. Each stream's metadata includes file_id, web_url, file_name, and content_type.

Source Code

To check this component's source code, open fetcher.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  GoogleDriveFetcher:
type: haystack_integrations.components.fetchers.google_drive.fetcher.GoogleDriveFetcher
init_parameters: {}

Using the Component in a Pipeline

# haystack-pipeline
components:
oauth_resolver:
type: haystack_integrations.components.connectors.oauth.resolver.OAuthTokenResolver
init_parameters:
token_source:
type: haystack_integrations.utils.oauth.sources.OAuthRefreshTokenSource
init_parameters:
token_url: https://oauth2.googleapis.com/token
client_id: your-client-id
refresh_token:
type: env_var
env_vars:
- GOOGLE_REFRESH_TOKEN
strict: false
scopes:
- https://www.googleapis.com/auth/drive.readonly

retriever:
type: haystack_integrations.components.retrievers.google_drive.retriever.GoogleDriveRetriever
init_parameters:
top_k: 5

fetcher:
type: haystack_integrations.components.fetchers.google_drive.fetcher.GoogleDriveFetcher
init_parameters: {}

connections:
- sender: oauth_resolver.access_token
receiver: retriever.access_token
- sender: oauth_resolver.access_token
receiver: fetcher.access_token
- sender: retriever.documents
receiver: fetcher.targets

inputs:
query:
- retriever.query

outputs:
streams: fetcher.streams

Parameters

Inputs

ParameterTypeDescription
access_tokenstr | SecretDelegated Google OAuth bearer token for the user whose files are fetched.
targetsList[Document | str]Files to fetch as Document objects from GoogleDriveRetriever or raw file IDs and Drive URLs.

Outputs

ParameterTypeDescription
streamsList[ByteStream]Fetched file content. Each stream's metadata includes file_id, web_url, file_name, and content_type.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_base_urlstrhttps://www.googleapis.com/drive/v3The Drive API base URL.
timeoutfloat30.0HTTP timeout in seconds for each Drive API request.
max_retriesint3Maximum retries for throttled or transient server errors.
max_concurrent_requestsint5Maximum concurrent file fetches in run_async.
raise_on_failureboolTrueIf True, a fetch failure raises an exception. If False, the file is skipped.
export_mime_typesDict[str, str] | NoneNoneMapping of native Google mime types to export formats. Defaults to Docs/Sheets/Slides exported as DOCX/XLSX/PPTX.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
access_tokenstr | SecretDelegated Google OAuth bearer token.
targetsList[Document | str]Files to fetch.