Skip to main content
Enable Agno agents to read, create, update and duplicate Google Drive files.
  • File Discovery, list files, upload/download files
  • Content Retrieval
  • Automated Management
  • Collaborative Context

Prerequisites

  • Set up Google Authentication:
      1. Go to the Google Cloud Console.
      1. Navigate to “APIs & Services” > “Credentials”.
      1. Select your OAuth 2.0 Client ID from the list.
      1. In the “Authorized redirect URIs” section, click “Add URI”.
      1. Enter the complete redirect URI, with the port number included (e.g., http://localhost:5050).
      1. Click “Save” to apply the changes.
  • Set up environment variables to specify the GOOGLE_AUTH_PORT and GOOGLE_CLOUD_QUOTA_PROJECT_ID.

from agno.agent import Agent
from agno.tools.google_drive import GoogleDriveTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

google_drive_tools = GoogleDriveTools(auth_port=5050)

agent = Agent(
    tools=[google_drive_tools],
    instructions=[
        "You help users interact with Google Drive using tools that use the Google Drive API",
        "Before asking for file details, first attempt the operation as the user may have already configured the credentials in the constructor",
    ],
)

# Example 1: List files in Google Drive

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("Please list the files in my Google Drive")

    # Example 2: Upload a file to Google Drive
    # file_path = ...
    # agent.print_response(
    #     "Please upload this file to my Google Drive", files=[File(path=file_path)]
    # )

    # Example 3: Download a file from Google Drive
    # agent.print_response(
    #     "Please download the 'test.txt' file from my Google Drive. It's in the 'test_files' folder."
    # )

Run the Example

# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python google_drive.py
For details, see Google Drive cookbook.