enhancementgood first issueintegrationnew-featurenew-integration
Repository-Metriken
- Stars
- (1.930 Sterne)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
Description
Add Google Drive integration to sync file activity, document metadata, comments, and sharing events into CORE.
Reference Implementations
Existing Integrations (use as templates)
integrations/github/- Similar event-driven systemintegrations/linear/- Project management integrationintegrations/slack/- For messaging reference
Required Files Structure
integrations/google-drive/
├── src/
│ ├── index.ts # Main entry, OAuth spec
│ ├── schedule.ts # Sync logic
│ ├── utils.ts # Google Drive API utilities
│ ├── account-create.ts # OAuth setup
│ └── create-activity.ts # Activity formatting
├── package.json
├── tsup.config.ts
└── README.md
Google Drive API Integration
OAuth Setup
- Use OAuth 2.0 (Authorization Code Grant)
- Authorization URL:
https://accounts.google.com/o/oauth2/v2/auth - Token URL:
https://oauth2.googleapis.com/token - Revoke URL:
https://oauth2.googleapis.com/revoke - Required scopes:
https://www.googleapis.com/auth/drive.readonly- Read-only access to file metadata and contenthttps://www.googleapis.com/auth/drive.metadata.readonly- Read-only access to file metadatahttps://www.googleapis.com/auth/drive.activity.readonly- Read-only access to Drive activityhttps://www.googleapis.com/auth/drive.file- Per-file access to files created/opened by the app
Base URL
https://www.googleapis.com/drive/v3- Activity API:
https://driveactivity.googleapis.com/v2
Key Endpoints
GET /drive/v3/files- List filesGET /drive/v3/files/{fileId}- Get file metadataPOST /drive/v3/files- Create file metadataPATCH /drive/v3/files/{fileId}- Update file metadataDELETE /drive/v3/files/{fileId}- Delete a fileGET /drive/v3/files/{fileId}/export- Export a Google Workspace documentPOST /drive/v3/files/{fileId}/download- Download file contentGET /drive/v3/files/{fileId}/comments- List comments on a filePOST /drive/v3/files/{fileId}/comments- Add a commentGET /drive/v3/files/{fileId}/comments/{commentId}/replies- List comment repliesGET /drive/v3/files/{fileId}/permissions- List permissionsPOST /drive/v3/files/{fileId}/permissions- Share a fileGET /drive/v3/files/{fileId}/revisions- List file revisionsGET /drive/v3/changes/startPageToken- Get starting page token for changesGET /drive/v3/changes- List changes to filesPOST /drive/v3/changes/watch- Watch for changes (push notifications)GET /drive/v3/drives- List shared drivesPOST /v2/activity:query- Query Drive activity (Drive Activity API)
Events to Track
-
File Events
- File created
- File modified/edited
- File renamed
- File moved
- File deleted/trashed
- File restored
-
Sharing Events
- File shared with user/group
- Sharing permissions changed
- File unshared
- Link sharing enabled/disabled
-
Comment Events
- Comment added
- Comment replied to
- Comment resolved
- Comment deleted
-
Organizational Events
- Folder created/moved/deleted
- File added to/removed from shared drive
Implementation Tasks
- Set up basic integration structure following
integrations/github/src/index.tspattern - Implement OAuth 2.0 flow in
account-create.tswith Google-specific consent screen - Create Google Drive API utilities in
utils.ts - Implement sync logic in
schedule.tsusing Changes API for incremental sync - Integrate Drive Activity API for detailed activity tracking
- Set up push notifications via
changes/watchfor real-time updates - Convert Google Drive events to CORE activity format
- Handle Google Workspace document types (Docs, Sheets, Slides)
- Add error handling and rate limiting
- Create integration documentation
- Add to
integrations/README.md
Technical Notes
- Google Drive API v3 is the current version
- Use the Changes API with page tokens for efficient incremental sync
- Drive Activity API v2 provides richer activity details than the Changes API alone
- Push notifications via webhooks require a verified domain
- Google Workspace documents (Docs, Sheets, Slides) use export endpoint instead of download
- Export content limited to 10 MB per file
- Rate limit: 12,000 queries per minute per project (default)
- Shared drives have different permission models than My Drive
- Files can have multiple parents (shortcuts) in Drive v3
- OAuth consent screen requires Google Cloud Console configuration and verification for sensitive scopes
Resources
- Google Drive API v3 Reference
- Google Drive API Scopes
- Google OAuth 2.0 for Web Server Apps
- Drive Activity API v2
- Google Drive Changes API
- Files: export
- Files: download
Labels
enhancement, integration, new-feature