enhancementgood first issueintegrationnew-featurenew-integration
Repository metrics
- Stars
- (1,930 stars)
- PR merge metrics
- (Avg merge 3h 2m) (10 merged PRs in 30d)
Description
Description
Add OneDrive integration to sync files, folders, and document activity into CORE via Microsoft Graph API.
Reference Implementations
Existing Integrations (use as templates)
integrations/google-docs/- Similar cloud document integrationintegrations/google-sheets/- Google Workspace file integrationintegrations/github/- For webhook and event patterns
Required Files Structure
integrations/onedrive/
├── src/
│ ├── index.ts # Main entry, OAuth spec
│ ├── schedule.ts # Sync logic
│ ├── utils.ts # Microsoft Graph API utilities
│ ├── account-create.ts # OAuth setup
│ └── create-activity.ts # Activity formatting
├── package.json
├── tsup.config.ts
└── README.md
OneDrive API Integration (via Microsoft Graph)
OAuth Setup
- Use OAuth 2.0 with Microsoft Identity Platform
- Microsoft Graph base URL:
https://graph.microsoft.com/v1.0 - Required scopes:
Files.Read- Read user's filesFiles.Read.All- Read all files user can accessFiles.ReadWrite- Read and write user's filesUser.Read- Read user profileoffline_access- Refresh tokens for long-lived access
Key Endpoints
GET /me/drive- Get current user's OneDriveGET /me/drive/root/children- List items in root folderGET /me/drive/items/{item-id}- Get item metadataGET /me/drive/items/{item-id}/children- List folder contentsGET /me/drive/root:/{path}- Access items by pathGET /me/drive/items/{item-id}/content- Download file contentGET /drives/{drive-id}/items/{item-id}- Access shared drivesGET /me/drive/items/{item-id}/delta- Track changes (delta sync)POST /subscriptions- Create webhook subscriptions for change notifications
Core Resources
- Drive - Logical container of files (document library or user's OneDrive)
- DriveItem - Item within a drive (document, photo, video, folder)
Events to Track
- Files - File created, modified, renamed, deleted, moved
- Folders - Folder created, renamed, deleted, reorganized
- Sharing - Files shared, permissions changed
- Versions - File version history changes
- Sync Activity - Delta changes for incremental sync
Implementation Tasks
- Set up basic integration structure following
integrations/github/src/index.tspattern - Implement OAuth 2.0 flow with Microsoft Identity Platform in
account-create.ts - Create API utilities in
utils.tsfor Microsoft Graph API - Implement sync logic in
schedule.tsusing delta queries for incremental sync - Set up webhook subscriptions for real-time change notifications
- Convert OneDrive events to CORE activity format
- Add error handling and rate limiting
- Create integration documentation
- Add to
integrations/README.md
Technical Notes
- OneDrive is accessed through the Microsoft Graph API, not a standalone API
- URL pattern:
https://graph.microsoft.com/v1.0/{root-resource}/{onedrive-resource} - Delta queries (
/deltaendpoint) enable efficient incremental sync - Webhook subscriptions require a publicly accessible notification URL
- Both personal OneDrive and OneDrive for Business are supported
- The same API can access SharePoint document libraries
Resources
- OneDrive File Storage API Overview
- Working with Files in Microsoft Graph
- OneDrive REST API Getting Started
- OneDrive API Docs (GitHub)
- Microsoft Graph API - Get Drive
Labels
enhancement, integration, new-feature