Address gaps found in verification: - Fix Google and Apple OAuth callbacks to use real API token exchanges - Complete calendar event fetching with real API integrations - Implement bidirectional sync with actual database/calendar operations - Enable functional calendar connection UI with real OAuth triggers
6.4 KiB
6.4 KiB
| phase | plan | type | wave | depends_on | files_modified | autonomous | gap_closure | must_haves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 03-calendar-integration | 04 | execute | 1 |
|
true | true |
|
Gap Closure: Calendar OAuth Implementation
Objective
Fix incomplete Google and Apple Calendar OAuth implementations to enable real calendar account connections.
Purpose
Enable users to securely connect their Google and Apple Calendar accounts through proper OAuth flows.
Output
Functional OAuth endpoints that exchange authorization codes for real tokens and store them securely in the database.
Tasks
Fix Google OAuth Callback with Real Token Exchange src/app/api/calendar/google/oauth/route.ts Replace the current placeholder implementation with a real token exchange:1. Remove hardcoded mock tokens from the implementation
2. Implement real API call to exchange the authorization code for access and refresh tokens using the Google OAuth2 API
3. Store valid tokens in the database using Prisma ORM instead of console logging
4. Add proper error handling for token exchange failures with informative messages
5. Implement token validation to ensure they're valid before saving
The implementation should:
- Call the Google OAuth2 token endpoint with the authorization code
- Handle successful token exchange results
- Handle and log token exchange errors appropriately
- Store the tokens in the CalendarConnection database record
Run `curl -X GET "http://localhost:3000/api/calendar/google/oauth?code=valid_code"` and verify tokens are stored in database instead of just console logged
Google OAuth callback endpoint exchanges real tokens and stores them in database
Fix Apple OAuth Callback with Real Token Exchange
src/app/api/calendar/apple/oauth/route.ts
Replace the current placeholder implementation with a real token exchange:
1. Remove hardcoded mock tokens from the implementation
2. Implement real API call to exchange the authorization code for access and refresh tokens using Apple's OAuth2 API
3. Store valid tokens in the database using Prisma ORM instead of console logging
4. Add proper error handling for token exchange failures with informative messages
5. Implement token validation to ensure they're valid before saving
The implementation should:
- Make a POST request to Apple's token endpoint with code, client_id, client_secret, and redirect_uri
- Handle successful token exchange results
- Handle and log token exchange errors appropriately
- Store the tokens in the CalendarConnection database record
Run `curl -X GET "http://localhost:3000/api/calendar/apple/oauth?code=valid_code"` and verify tokens are stored in database instead of just console logged
Apple OAuth callback endpoint exchanges real tokens and stores them in database
Implement Database Storage for OAuth Tokens
prisma/schema.prisma
Update the CalendarConnection model to include necessary fields for storing OAuth tokens properly:
1. Ensure the model has all required fields for storing tokens (access_token, refresh_token, expires_at)
2. Add proper database constraints and validations
3. Ensure relationships with User model are properly defined
Currently, we have proper fields, but we need to make sure:
- The model properly supports both Google and Apple token formats
- Fields are properly indexed for performance
- The relationship with User is correctly defined
Check that prisma/schema.prisma defines CalendarConnection model with userId, provider, accessToken, refreshToken, expiresAt fields
CalendarConnection model properly defined with all required fields for OAuth token storage
Verification
After completing these tasks, the following checks should pass:
- Google OAuth callback exchanges real tokens instead of using placeholders
- Apple OAuth callback exchanges real tokens instead of using placeholders
- OAuth tokens are stored in the database properly instead of just logged
- All error cases have proper handling and reporting
Success Criteria
All gaps identified in the VERIFICATION.md for Google and Apple OAuth implementations are resolved:
- OAuth endpoints use real API token exchange instead of placeholder implementations
- OAuth tokens are securely stored in the database
- Proper error handling for token exchange failures