callumalpass_tasknotes/.env.example
callumalpass f007bf1a7c
feat: add OAuth 2.0 calendar integration for Google and Microsoft Calendar (#997)
Adds comprehensive OAuth 2.0 integration for Google Calendar and Microsoft Calendar
with two authentication modes: Quick Setup (Device Flow) and Advanced Setup (standard
OAuth flow with user credentials).

## Features

**Calendar Providers**
- Google Calendar and Microsoft Calendar integration with full CRUD operations
- Unified CalendarProvider abstraction for extensibility
- Events display in Bases calendar view with drag-and-drop scheduling

**Authentication**
- Quick Setup: OAuth 2.0 Device Flow (RFC 8628) - requires license key, no OAuth app configuration needed
- Advanced Setup: Standard OAuth flow with PKCE - use your own Google Cloud/Azure credentials

**Sync & Performance**
- Incremental sync using sync tokens (Google) and delta links (Microsoft)
- Exponential backoff retry logic for rate limiting
- Token refresh with mutex pattern to prevent race conditions
- Automatic refresh every 15 minutes

## Technical Implementation

**New Services**
- OAuthService: OAuth flows, token management, and revocation
- GoogleCalendarService: Google Calendar API client
- MicrosoftCalendarService: Microsoft Graph API client
- LicenseService: Lemon Squeezy license validation
- CalendarProvider: Abstract base class for calendar integrations

**Error Handling**
- Custom error types for calendar operations
- Validation helpers for IDs and required fields
- Graceful handling of expired tokens and API errors

**Security**
- Device Flow uses only public client IDs (no secrets bundled)
- PKCE support for standard OAuth flow
- Tokens stored securely in Obsidian's data folder
- Token revocation on disconnect

## Testing

- Comprehensive test coverage: 1,423 tests passing
- Tests cover CRUD operations, error handling, rate limiting, and timezone handling
- Manually tested with real Google and Microsoft accounts

## Documentation

- Setup instructions in docs/calendar-setup.md
- Users configure via Settings → Integrations → Calendar
2025-10-26 16:40:35 +11:00

46 lines
2.1 KiB
Text

# OAuth Client IDs for Calendar Integration (Device Flow)
# These are PUBLIC identifiers - safe to bundle in plugin code
# ============================================================================
# IMPORTANT: Device Flow Security Model
# ============================================================================
#
# Device Flow (RFC 8628) only requires a PUBLIC client_id.
# NO client_secret is used or bundled (security requirement).
#
# How it works:
# 1. Plugin shows user a code (e.g., "ABCD-1234")
# 2. User visits google.com/device and enters code
# 3. Plugin polls Google for authorization result
# 4. No secrets needed anywhere in this flow!
#
# License requirement:
# - Users with valid TaskNotes license: Use built-in client_id (easy setup)
# - Users without license: Must provide their own OAuth credentials in settings
#
# ============================================================================
# Google Calendar OAuth Client ID (Public identifier for Device Flow)
# Get this from: https://console.cloud.google.com/apis/credentials
# Application type: "Desktop app" or "TVs and Limited Input devices"
GOOGLE_OAUTH_CLIENT_ID=your-client-id.apps.googleusercontent.com
# Microsoft OAuth Client ID (Public identifier for Device Flow)
# Get this from: https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps
# Platform: "Mobile and desktop applications"
# Redirect URI: Not needed for Device Flow
MICROSOFT_OAUTH_CLIENT_ID=your-microsoft-client-id
# ============================================================================
# DO NOT ADD client_secret HERE
# ============================================================================
# Secrets are NOT bundled into the plugin for security reasons.
# See OAUTH_CALENDAR_ISSUES.md for detailed security analysis.
#
# Device Flow doesn't require secrets, making this approach both:
# - Secure (no secrets in code)
# - Simple (users just enter license key)
#
# For development/testing: Create your own OAuth apps following:
# docs/planning/oauth-setup-guide.md
# ============================================================================