RedPlanetHQ/core

New Integration: Google Drive

Offen

#173 geöffnet am 21.11.2025

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (184 Forks)auto 404
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 system
  • integrations/linear/ - Project management integration
  • integrations/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 content
    • https://www.googleapis.com/auth/drive.metadata.readonly - Read-only access to file metadata
    • https://www.googleapis.com/auth/drive.activity.readonly - Read-only access to Drive activity
    • https://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 files
  • GET /drive/v3/files/{fileId} - Get file metadata
  • POST /drive/v3/files - Create file metadata
  • PATCH /drive/v3/files/{fileId} - Update file metadata
  • DELETE /drive/v3/files/{fileId} - Delete a file
  • GET /drive/v3/files/{fileId}/export - Export a Google Workspace document
  • POST /drive/v3/files/{fileId}/download - Download file content
  • GET /drive/v3/files/{fileId}/comments - List comments on a file
  • POST /drive/v3/files/{fileId}/comments - Add a comment
  • GET /drive/v3/files/{fileId}/comments/{commentId}/replies - List comment replies
  • GET /drive/v3/files/{fileId}/permissions - List permissions
  • POST /drive/v3/files/{fileId}/permissions - Share a file
  • GET /drive/v3/files/{fileId}/revisions - List file revisions
  • GET /drive/v3/changes/startPageToken - Get starting page token for changes
  • GET /drive/v3/changes - List changes to files
  • POST /drive/v3/changes/watch - Watch for changes (push notifications)
  • GET /drive/v3/drives - List shared drives
  • POST /v2/activity:query - Query Drive activity (Drive Activity API)

Events to Track

  1. File Events

    • File created
    • File modified/edited
    • File renamed
    • File moved
    • File deleted/trashed
    • File restored
  2. Sharing Events

    • File shared with user/group
    • Sharing permissions changed
    • File unshared
    • Link sharing enabled/disabled
  3. Comment Events

    • Comment added
    • Comment replied to
    • Comment resolved
    • Comment deleted
  4. 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.ts pattern
  • Implement OAuth 2.0 flow in account-create.ts with Google-specific consent screen
  • Create Google Drive API utilities in utils.ts
  • Implement sync logic in schedule.ts using Changes API for incremental sync
  • Integrate Drive Activity API for detailed activity tracking
  • Set up push notifications via changes/watch for 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

Labels

enhancement, integration, new-feature

Contributor Guide