> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Run the Google Drive Connector Externally

> Use YAML to configure Google Drive ingestion, enabling structured metadata extraction for files, folders, and Google Sheets.

![Google Drive](https://docs.open-metadata.org/public/images/connectors/googledrive.webp)

# Google Drive

BETA

In this section, we provide guides and references to use the Google Drive connector.
Configure and schedule Google Drive metadata workflows from the OpenMetadata UI:

* [Requirements](#requirements)
* [Metadata Ingestion](#metadata-ingestion)

## How to Run the Connector Externally

To run the Ingestion via the UI you'll need to use the OpenMetadata Ingestion Container, which comes shipped with
custom Airflow plugins to handle the workflow deployment.

If, instead, you want to manage your workflows externally on your preferred orchestrator, you can check
the following docs to run the Ingestion Framework **anywhere**.

> [card] [External Schedulers](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Get more information about running the Ingestion Framework Externally

## Requirements

Before configuring the Google Drive connector, make sure the following requirements are in place.

### Python Requirements

Use Python 3.10 or later. Python 3.12 is recommended, because it is what the OpenMetadata 2.0 ingestion images use. To confirm the supported range for your release, check the `Requires-Python` metadata of that release’s `openmetadata-ingestion` package.

To run the Google Drive ingestion, you will need to install:

```bash theme={null}
pip3 install "openmetadata-ingestion[googledrive]"
```

## Metadata Ingestion

All connectors are defined as JSON Schemas.
[Here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/drive/googleDriveConnection.json)
you can find the structure to create a connection to Google Drive.
In order to create and run a Metadata Ingestion workflow, we will follow
the steps to create a YAML configuration able to connect to the source,
process the Entities if needed, and reach the OpenMetadata server.
The workflow is modeled around the following
[JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/workflow.json)

### 1. Define the YAML Config

This is a sample config for Google Drive:

#### Source Configuration

Configure the source type and service name for your Google Drive connector.

#### GCP Credentials

**credentials**: GCP service account credentials used to access the Google Drive API. Provide the key file contents directly, or omit this block to fall back to [ADC authentication](https://cloud.google.com/docs/authentication#adc).

#### Delegated Email

**delegatedEmail** (Optional): Email address to impersonate using domain-wide delegation.

#### Drive ID

**driveId** (Optional): Specific shared drive ID to connect to. Leave unset to process all accessible drives.

#### Include Team Drives

**includeTeamDrives**: Include shared/team drives in metadata extraction. Defaults to `true`.

#### Include Google Sheets

**includeGoogleSheets**: Extract metadata for Google Sheets files. Defaults to `false`.

#### Filter Patterns

**directoryFilterPattern**, **fileFilterPattern**, **spreadsheetFilterPattern**, **worksheetFilterPattern** (all Optional): Regex to only include/exclude directories, files, spreadsheets, or worksheets that match the pattern.

#### Source Config

Configure Drive metadata ingestion options for Google Drive: which entity types to include, deletion handling, owners, and filter patterns.

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

#### Workflow Configuration

The main property here is `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.

* **loggerLevel**: Specify the logger level depending on your needs. If you are troubleshooting an ingestion, use `DEBUG` for more detailed traces.
* **JWT token**: JWT tokens allow clients to authenticate against the OpenMetadata server. See [Enable JWT Tokens](https://docs.open-metadata.org/deployment/security/enable-jwt-tokens) and [JWT Troubleshooting](https://docs.open-metadata.org/deployment/security/jwt-troubleshooting) for more information.
* **storeServiceConnection**: If set to `true` (default), sensitive information is stored encrypted with the Fernet Key or externally if you have configured a [Secrets Manager](https://docs.open-metadata.org/deployment/secrets-manager). If set to `false`, the service is created, but the service connection information is only used by the Ingestion Framework at runtime and is not sent to the OpenMetadata server.
* **SSL configuration**: If you have added SSL to the [OpenMetadata server](https://docs.open-metadata.org/deployment/security/enable-ssl), configure the certificates for ingestion. Set `verifySSL` to `ignore`, or set it to `validate` and provide `sslConfig.caCertificate` with a local path to the server certificate. See [SSL Troubleshooting](https://docs.open-metadata.org/deployment/security/enable-ssl/ssl-troubleshooting) for more information.
* **ingestionPipelineFQN**: Fully qualified name of the ingestion pipeline, used to identify the current ingestion pipeline.

googledrive\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: googledrive
  serviceName: local_googledrive
  serviceConnection:
    config:
      type: GoogleDrive
      credentials:
        gcpConfig:
          type: service_account
          projectId: my-gcp-project
          privateKeyId: "9dd8...db55"
          privateKey: |
            -----BEGIN PRIVATE KEY-----
            <your_private_key_content>
            -----END PRIVATE KEY-----
          clientEmail: gdrive-connector@my-gcp-project.iam.gserviceaccount.com
          clientId: "1234567890"
          authUri: https://accounts.google.com/o/oauth2/auth
          tokenUri: https://oauth2.googleapis.com/token
          authProviderX509CertUrl: https://www.googleapis.com/oauth2/v1/certs
          clientX509CertUrl: https://www.googleapis.com/robot/v1/metadata/x509/gdrive-connector%40my-gcp-project.iam.gserviceaccount.com
      # delegatedEmail: user@yourcompany.com
      # driveId: 0AbCdEfGhIjKlMnOpQ
      includeTeamDrives: true
      includeGoogleSheets: false
      # directoryFilterPattern:
      #   includes:
      #     - /Reports/.*
      #   excludes:
      #     - /Archive/.*
      # fileFilterPattern:
      #   includes:
      #     - .*\.pdf
      #   excludes:
      #     - .*_backup\..*
      # spreadsheetFilterPattern:
      #   includes:
      #     - ^report_.*
      # worksheetFilterPattern:
      #   includes:
      #     - ^Summary.*
```

```yaml theme={null}
  sourceConfig:
    config:
      type: DriveMetadata
      markDeletedDirectories: true
      markDeletedFiles: true
      markDeletedSpreadsheets: true
      markDeletedWorksheets: true
      includeDirectories: true
      includeFiles: true
      includeSpreadsheets: true
      includeWorksheets: true
      includeTags: true
      includeOwners: false
      overrideMetadata: false
      useFqnForFiltering: false
      # directoryFilterPattern:
      #   includes:
      #     - /Reports/.*
      #   excludes:
      #     - /Archive/.*
      # fileFilterPattern:
      #   includes:
      #     - .*\.pdf
      #     - .*\.docx
      #   excludes:
      #     - .*_backup\..*
      # spreadsheetFilterPattern:
      #   includes:
      #     - ^report_.*
      #   excludes:
      #     - ^draft_.*
      # worksheetFilterPattern:
      #   includes:
      #     - ^Summary.*
      #   excludes:
      #     - ^Sheet\d+$
      threads: 1
```

```yaml theme={null}
sink:
  type: metadata-rest
  config: {}
```

```yaml theme={null}
workflowConfig:
  loggerLevel: INFO  # DEBUG, INFO, WARNING or ERROR
  openMetadataServerConfig:
    hostPort: "http://localhost:8585/api"
    authProvider: openmetadata
    securityConfig:
      jwtToken: "{bot_jwt_token}"
    ## Store the service Connection information
    storeServiceConnection: true  # false
    ## Secrets Manager Configuration
    # secretsManagerProvider: aws, azure or noop
    # secretsManagerLoader: airflow or env
    ## If SSL, fill the following
    # verifySSL: validate  # or ignore
    # sslConfig:
    #   caCertificate: /local/path/to/certificate
# ingestionPipelineFQN: <service name>.<ingestion name> ## e.g., "my_redshift.metadata"
```

### Configuration Examples

The following examples show common Google Drive configurations.

#### Service Account with Domain-Wide Delegation

This example uses domain-wide delegation to access shared drives across the organization.

```yaml theme={null}
source:
  type: googledrive
  serviceName: googledrive_prod
  serviceConnection:
    config:
      type: GoogleDrive
      credentials:
        gcpConfig:
          type: service_account
          projectId: my-gcp-project
          privateKeyId: "9dd8...db55"
          privateKey: |
            -----BEGIN PRIVATE KEY-----
            <your_private_key_content>
            -----END PRIVATE KEY-----
          clientEmail: gdrive-connector@my-gcp-project.iam.gserviceaccount.com
          clientId: "1234567890"
          authUri: https://accounts.google.com/o/oauth2/auth
          tokenUri: https://oauth2.googleapis.com/token
          authProviderX509CertUrl: https://www.googleapis.com/oauth2/v1/certs
          clientX509CertUrl: https://www.googleapis.com/robot/v1/metadata/x509/gdrive-connector%40my-gcp-project.iam.gserviceaccount.com
      delegatedEmail: shared-drives@yourcompany.com
      includeTeamDrives: true
```

#### Google Sheets Ingestion with Filtering

This example restricts ingestion to Google Sheets and applies spreadsheet and worksheet filter patterns.

```yaml theme={null}
source:
  type: googledrive
  serviceName: googledrive_analytics
  serviceConnection:
    config:
      type: GoogleDrive
      credentials:
        gcpConfig:
          type: service_account
          projectId: my-gcp-project
          privateKeyId: "9dd8...db55"
          privateKey: |
            -----BEGIN PRIVATE KEY-----
            <your_private_key_content>
            -----END PRIVATE KEY-----
          clientEmail: gdrive-connector@my-gcp-project.iam.gserviceaccount.com
          clientId: "1234567890"
          authUri: https://accounts.google.com/o/oauth2/auth
          tokenUri: https://oauth2.googleapis.com/token
          authProviderX509CertUrl: https://www.googleapis.com/oauth2/v1/certs
          clientX509CertUrl: https://www.googleapis.com/robot/v1/metadata/x509/gdrive-connector%40my-gcp-project.iam.gserviceaccount.com
      includeGoogleSheets: true
      spreadsheetFilterPattern:
        includes:
          - ^report_.*
        excludes:
          - ^draft_.*
      worksheetFilterPattern:
        includes:
          - ^Summary.*
        excludes:
          - ^Sheet\d+$
```

### 2. Run with the CLI

First, we will need to save the YAML file. Afterward, and with all requirements installed, we can run:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

Note that from connector to connector, this recipe will always be the same. By updating the YAML configuration,
you will be able to extract metadata from different sources.

## Related

> [card] [Configure Ingestion Externally](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Deploy, configure, and manage the ingestion workflows externally.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.