Skip to content

Add Google Drive and OneDrive sync providers with OAuth 2.0 authentication#595

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/add-google-drive-onedrive-sync
Draft

Add Google Drive and OneDrive sync providers with OAuth 2.0 authentication#595
Copilot wants to merge 7 commits intomainfrom
copilot/add-google-drive-onedrive-sync

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

Adds Google Drive and OneDrive as sync service providers following the existing WebDAV pattern. Implements OAuth 2.0 with PKCE through modal webview for authentication.

Implementation

6 New Sync Services (Data/Image/PDF variants):

  • GoogleDriveDataSyncService, GoogleDriveImageSyncService, GoogleDrivePDFSyncService
  • OneDriveDataSyncService, OneDriveImageSyncService, OneDrivePDFSyncService
  • Registered in SERVICES_TYPE_MAP and SYNC_TYPES

OAuth Infrastructure:

  • OAuthHelper.ts - OAuth 2.0 flow with PKCE, token refresh, secure storage
  • OAuthWebViewModal.svelte - Modal webview intercepts redirect URI with auth code
  • OAuthSettingsView.svelte - Reusable authentication UI component

Provider APIs:

  • GoogleDrive.ts - Drive API v3 wrapper (multipart upload, folder ops, file CRUD)
  • OneDrive.ts - Microsoft Graph API wrapper (simple upload, item navigation)

UI Integration:

  • GoogleDriveDataSyncSettings.svelte - Settings screen with OAuth flow
  • Updated SyncListSettings.svelte to handle new service types
  • Added service titles and colors in sync.ts

Architecture

Follows existing patterns:

export class GoogleDriveDataSyncService extends BaseDataSyncService {
    private get tokens(): OAuthTokens {
        return { accessToken: this.accessToken, refreshToken: this.refreshToken, expiresAt: this.expiresAt };
    }
    
    override async ensureRemoteFolder() {
        this.remoteFolderId = await getOrCreateFolder(this.tokens, this.remoteFolder);
    }
    
    override async addDocumentToRemote(document: OCRDocument) {
        await this.sendFolderToRemote(docFolder, document.id);
        await this.putFileContentsFromData(path.join(document.id, DOCUMENT_DATA_FILENAME), document.toString());
        await this.createValidMarker(document.id);
    }
}

Uses existing dependencies only:

  • @nativescript-community/ui-webview for OAuth modal
  • @nativescript-community/https for API requests

Configuration Required

⚠️ OAuth client IDs are placeholders - users must create their own OAuth applications:

Google Drive: Update GOOGLE_DRIVE_PROVIDER.config.clientId in GoogleDrive.ts
OneDrive: Update ONEDRIVE_PROVIDER.config.clientId in OneDrive.ts

See CLOUD_SYNC_SETUP.md for credential setup instructions.

Limitations

  • Simple upload only (no resumable for large files >4MB)
  • No rate limiting or exponential backoff
  • Basic conflict resolution (newer overwrites)
  • Requires OAuth app configuration per deployment

Files Changed

18 files, 2,544 lines added:

  • 11 new service/helper files
  • 4 new UI components
  • 3 documentation files

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 4 commits March 24, 2026 10:18
…view and documentation

Co-authored-by: farfromrefug <655344+farfromrefug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Akylas/OSS-DocumentScanner/sessions/e44ecfbf-dc8f-47c0-b15c-1bbe320da960
Co-authored-by: farfromrefug <655344+farfromrefug@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Akylas/OSS-DocumentScanner/sessions/e44ecfbf-dc8f-47c0-b15c-1bbe320da960
Copilot AI changed the title [WIP] Add new sync service providers for Google Drive and OneDrive Add Google Drive and OneDrive sync providers with OAuth 2.0 authentication Mar 24, 2026
Copilot AI requested a review from farfromrefug March 24, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants