Google Drive Datasource Plugin
Author: langgenius
Version: 0.1.5
Type: datasource
Introduction
This plugin integrates with Google Drive, enabling automated access to your files and folders stored in Google Drive. It supports browsing files, navigating folders, and downloading files directly for use in platforms like Dify. The plugin also handles Google Workspace files (Docs, Sheets, Slides) by exporting them to compatible formats.
Features
- Browse Files and Folders: Navigate through your Google Drive directory structure
- Download Files: Retrieve files from Google Drive for processing
- Google Workspace Support: Automatic export of Google Docs, Sheets, and Slides to compatible formats
- Folder Navigation: Support for hierarchical folder structure browsing
- Pagination Support: Efficiently handle large numbers of files with pagination
- OAuth 2.0 Authentication: Secure authentication using Google's OAuth 2.0 flow
Setup
Prerequisites
Before using this plugin, you need:
- A Google account with Google Drive enabled
- Access to Google Cloud Console to create OAuth 2.0 credentials
- Files in your Google Drive that you want to access
Configuration Steps
-
Create a Google Cloud Project:
- Go to Google Cloud Console
- Click "Create Project" or select an existing project
- Give your project a name (e.g., "Dify Google Drive Plugin")
-
Enable Google Drive API:
- In your Google Cloud project, go to "APIs & Services" → "Library"
- Search for "Google Drive API"
- Click on it and press "Enable"
-
Create OAuth 2.0 Credentials:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- If prompted, configure the OAuth consent screen first:
- User Type: Choose based on your needs (Internal for organization use, External for general use)
- App name: Dify Google Drive Plugin
- User support email: Your email address
- Developer contact information: Your email address
- For the OAuth client ID:
- Application type: Web application
- Name: Dify Google Drive Plugin
- Authorized redirect URIs:
- For SaaS (cloud.dify.ai) users:
- For self-hosted users:
- Replace with your actual console API URL
-
Configure OAuth Consent Screen:
- Add the following OAuth scopes:
- - View and download all files
- - View metadata for files
- Add test users if your app is in testing mode
-
Get Your Credentials:
- After creating the OAuth client, copy:
- Keep these secure as they will be needed in Dify
-
Configure the Plugin in Dify:
- Navigate to the datasource plugins section in Dify
- Select Google Drive
- Enter your Client ID and Client Secret
- Click "Save and authorize"
- You'll be redirected to Google's OAuth consent page
- Grant the necessary permissions
- You'll be redirected back to Dify upon successful authorization
Usage
Browsing Files
The plugin provides an interface for browsing Google Drive content:
- Root Directory: Start by browsing from the root of your Google Drive
- Folder Navigation: Click on folders to browse their contents
- File Information: View file names, sizes, and types
- Pagination: Navigate through pages when you have many files
Downloading Files
To download a file:
- Browse to locate the desired file
- Select the file for download
- The plugin retrieves the file content and metadata
Google Workspace Files
The plugin automatically handles Google Workspace files:
- Google Docs: Exported as PDF
- Google Sheets: Exported as Excel (XLSX)
- Google Slides: Exported as PDF
- Google Drawings: Exported as PNG
- Google Forms: Exported as PDF
Supported Operations
| Operation | Description |
|---|
| List Files | Browse files and folders in Google Drive |
| Navigate Folders | Access files within specific folders |
| Download File | Retrieve file content from Google Drive |
| Export Workspace Files | Automatic conversion of Google Workspace files |
| Pagination | Handle large file lists with page tokens |
Troubleshooting
Common Issues
-
"Authentication failed (401 Unauthorized)" error:
- The access token has expired
- Solution: Reauthorize the connection in Dify settings
-
"File not found" error:
- The file may have been deleted or moved
- You may not have permission to access the file
- Solution: Verify the file exists and you have access
-
"Failed to list files" error:
- Check your internet connection
- Verify API quotas haven't been exceeded
- Ensure Google Drive API is enabled in your project
-
OAuth Authorization Issues:
- Verify redirect URI matches exactly (including protocol and trailing slashes)
- Check that all required scopes are configured
- Ensure client ID and secret are correct
-
Files Not Showing:
- Check if files are in trash (trashed files are not shown)
- Verify you have permission to view the files
- Ensure the parent folder ID is correct when browsing subfolders
API Quotas and Limits
Google Drive API has usage quotas:
- Queries per day: 1,000,000,000
- Queries per 100 seconds per user: 1,000
- Queries per 100 seconds: 10,000
If you encounter quota errors, wait before retrying or request a quota increase in Google Cloud Console.
Security Considerations
- OAuth 2.0: Uses secure OAuth 2.0 flow for authentication
- Token Storage: Access and refresh tokens are stored securely
- Minimal Permissions: Only requests read-only access to files
- HTTPS: All API communications use encrypted HTTPS connections
- Token Refresh: Automatically refreshes expired tokens when possible
Privacy
Please refer to the Privacy Policy for information on how your data is handled when using this plugin.
Support
For issues or questions:
Additional Resources
Last updated: September 2025