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

# Google Drive

> Connect Agentforce to Google Drive for file management, content access, and collaboration.

## Purpose and Capabilities

The Google Drive Connector empowers Agentforce agents to seamlessly interact with Google Drive, enabling comprehensive file management and content access directly within agent-driven workflows. Agents can search for files and folders, retrieve file content, upload new documents, create folders, manage permissions, and organize cloud storage. This integration facilitates automation of document-centric processes, enhances collaboration by allowing agents to share and manage access to files, and provides a robust way to integrate Google Drive's storage capabilities into various business applications.

## Key Tools

The Google Drive Connector provides a suite of tools for interacting with files and folders. Below are some of the primary tools available:

| Tool Name                           | Description                                                                  | Example Inputs                                                                                            |
| :---------------------------------- | :--------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------- |
| `google_drive_search_file`          | Searches for files or folders based on name, type, or other criteria.        | `query_string: "report_q3_final", parent_folder_id: "folder_123"`                                         |
| `google_drive_read_file`            | Reads the content of a specified file.                                       | `file_id: "file_abc_789"`                                                                                 |
| `google_drive_upload_file`          | Uploads a new file to a specified folder.                                    | `file_path: "/local/path/to/document.pdf", folder_id: "folder_xyz", file_name: "Uploaded Document.pdf"`   |
| `google_drive_create_folder`        | Creates a new folder in Google Drive.                                        | `folder_name: "New Project Alpha", parent_folder_id: "folder_root"`                                       |
| `google_drive_update_file`          | Updates the content or metadata of an existing file.                         | `file_id: "file_def_456", new_content_path: "/local/path/to/updated_version.docx"`                        |
| `google_drive_delete_item`          | Deletes a file or folder.                                                    | `item_id: "file_or_folder_id_to_delete"`                                                                  |
| `google_drive_share_file`           | Shares a file or folder with specified users or groups, setting permissions. | `file_id: "file_ghi_123", email_address: "user@example.com", role: "writer", notification_message: "FYI"` |
| `google_drive_list_folder_contents` | Lists all files and folders within a specified folder.                       | `folder_id: "folder_jkl_789"`                                                                             |

*(Note: Actual tool names and parameters may vary based on the final implementation.)*

## Prerequisites

Before you can use the Google Drive Connector, you need:

1. **A Google Account:** Access to Google Drive is managed through a Google account.
2. **Google Cloud Platform (GCP) Project:** You'll need a GCP project to enable the Google Drive API and create credentials.
3. **Google Drive API Enabled:** Ensure the Google Drive API is enabled for your GCP project.
4. **OAuth 2.0 Credentials:** You must create OAuth 2.0 credentials (Client ID and Client Secret) in your GCP project to allow the ACP connector to authenticate.
5. **Permissions:** The Google account used for authentication must have the necessary permissions to access the files and folders your agents will interact with.

## Setup Guide

Setting up the Google Drive Connector involves configuring OAuth 2.0 authentication to allow Agentforce to securely access your Google Drive.

1. **Create or Select a GCP Project:**
   * Go to the [Google Cloud Console](https://console.cloud.google.com/).
   * Create a new project or select an existing one.

2. **Enable the Google Drive API:**
   * In the GCP Console, navigate to "APIs & Services" > "Library".
   * Search for "Google Drive API" and enable it for your project.

3. **Configure OAuth Consent Screen:**
   * Navigate to "APIs & Services" > "OAuth consent screen".
   * Choose "Internal" or "External" user type. For most enterprise uses, "Internal" is appropriate if all users are within your Google Workspace organization. Otherwise, select "External".
   * Fill in the required application details (app name, user support email, developer contact information).
   * Add the necessary scopes for Google Drive. Common scopes include:
     * `https://www.googleapis.com/auth/drive` (Full access)
     * `https://www.googleapis.com/auth/drive.file` (Per-file access)
     * `https://www.googleapis.com/auth/drive.readonly` (Read-only access)
     * *(Consult the Google Drive API documentation for the precise scopes needed for your intended agent capabilities.)*
   * Add test users if your app is in "testing" mode (for external user types).

4. **Create OAuth 2.0 Credentials:**
   * Navigate to "APIs & Services" > "Credentials".
   * Click "+ CREATE CREDENTIALS" and select "OAuth client ID".
   * Choose "Web application" as the application type.
   * Give your client ID a name (e.g., "Agentforce ACP Connector").
   * Under "Authorized redirect URIs", add the redirect URI provided by Agentforce for ACP. This URI is crucial for the OAuth flow to complete successfully. *(This URI will be specific to your Agentforce ACP setup.)*
   * Click "Create". You will be shown a **Client ID** and **Client Secret**. **Securely store these credentials**, as they will be needed to configure the connector in Agentforce.

5. **Configure the Connector in Agentforce:**
   * In your Agentforce ACP configuration interface, navigate to the Google Drive Connector settings.
   * Enter the **Client ID** and **Client Secret** obtained in the previous step.
   * Initiate the authorization flow. You will be redirected to Google to grant permission for Agentforce to access your Google Drive on behalf of the authenticating user.
   * Once authorized, the connector will store the necessary tokens securely.

## Common Use Cases

* **Automated Report Archiving:** Agents can automatically upload generated reports or documents to specific folders in Google Drive.
* **Document Retrieval for Customer Support:** Support agents (or AI-powered virtual assistants) can quickly search and retrieve relevant documents (e.g., FAQs, manuals, customer files) from Google Drive to assist users.
* **Collaborative Document Workflows:** Agents can create new documents (e.g., from templates), share them with team members, and manage versions.
* **Data Collection from Shared Drives:** Agents can access and process data from files stored in shared Google Drive folders as part of larger data analysis workflows.
* **Backup and Synchronization:** Agents can be tasked with backing up important files from other systems to Google Drive.

## Troubleshooting Tips

* **Authentication Errors (401/403):**
  * Verify that the Client ID and Client Secret are correctly entered in Agentforce.
  * Ensure the Google Drive API is enabled in your GCP project.
  * Check that the correct OAuth scopes were requested and granted during the consent process.
  * Confirm the redirect URI in GCP matches the one used by Agentforce.
  * The user whose credentials are used for authentication must have access to the specific files/folders.
* **File Not Found Errors:**
  * Double-check the `file_id` or `folder_id` being used.
  * Ensure the authenticated user has permission to access the specified item.
* **API Rate Limits:**
  * Google Drive API has usage limits. If you encounter errors related to rate limiting, you may need to optimize your agent's API calls or request a quota increase from Google.
* **Scope Issues:**
  * If an agent cannot perform a specific action (e.g., delete a file when it should be able to), review the OAuth scopes granted to the application. You might need to re-authorize with additional scopes.
* **"App Not Verified" Screen:**
  * If you are using an "External" user type for the OAuth consent screen and haven't completed Google's app verification process, users might see a warning. For internal or trusted applications, this might be acceptable, but for broader use, app verification is recommended.

For further assistance, consult the official [Google Drive API documentation](https://developers.google.com/drive/api).
