Skip to content

Add Google Photos integration for importing photos#31

Open
SomeHats wants to merge 3 commits intomainfrom
claude/add-google-photos-integration-X08b4
Open

Add Google Photos integration for importing photos#31
SomeHats wants to merge 3 commits intomainfrom
claude/add-google-photos-integration-X08b4

Conversation

@SomeHats
Copy link
Owner

@SomeHats SomeHats commented Mar 2, 2026

Summary

This PR adds Google Photos integration to the photobook application, allowing users to browse and import photos directly from their Google Photos library without uploading files manually.

Key Changes

  • New Google Photos API module (googlePhotosApi.ts): Implements OAuth2 authentication using Google Identity Services (GIS) and integrates with the Google Photos Library API for:

    • Dynamic GIS script loading
    • OAuth2 token management with automatic refresh
    • Album listing and browsing
    • Media item search and filtering
    • Photo blob downloading with configurable dimensions
  • New Google Photos Picker component (GooglePhotosPicker.tsx): Multi-step UI for Google Photos integration:

    • Client ID setup screen with instructions for Google Cloud Console configuration
    • Authentication prompt with error handling
    • Album list view with cover photos and item counts
    • Photo grid view with multi-select capability
    • Import progress tracking and batch download
  • Enhanced PhotoPicker component: Integrated Google Photos picker alongside existing file upload:

    • Added toggle between local file upload and Google Photos import
    • New handleGoogleImport callback to process imported photos
    • Maintains existing file upload functionality
  • Extended useBookState hook: Added addPhotoFromBlob method to support importing photos from blob data (in addition to File objects), enabling flexible photo source handling

  • Minor import reorganization: Alphabetized imports across multiple files for consistency

Implementation Details

  • Uses localStorage to persist Google Client ID configuration
  • Implements automatic token refresh on 401 responses
  • Supports pagination for both albums and media items
  • Filters recent photos to show only PHOTO type media (excludes videos)
  • Downloads photos at configurable maximum dimensions (default 2048px)
  • Gracefully handles authentication errors with user-friendly messages
  • Maintains selection state during photo grid browsing

https://claude.ai/code/session_011atU8xw1b7RJTCgYdVBdf1

claude added 3 commits March 2, 2026 00:21
Add the ability to browse and import photos from Google Photos directly
into the photobook. Uses Google Identity Services for OAuth2 and the
Photos Library API for browsing albums and downloading photos.

New files:
- googlePhotosApi.ts: Auth layer (dynamic GIS loading, token management),
  API calls (albums, media items), and photo blob download
- GooglePhotosPicker.tsx: Custom picker UI with album browsing, photo
  grid with multi-select, import progress, and client ID setup flow

Modified files:
- PhotoPicker.tsx: Added "Import from Google Photos" button that toggles
  to the Google Photos picker view
- useBookState.tsx: Added addPhotoFromBlob() for importing downloaded
  blobs without needing a File object

https://claude.ai/code/session_011atU8xw1b7RJTCgYdVBdf1
The Client ID setup screen now shows a numbered guide walking through
creating a Google Cloud project, enabling the Photos Library API,
creating OAuth credentials, and adding the correct JavaScript origin.

https://claude.ai/code/session_011atU8xw1b7RJTCgYdVBdf1
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Preview deploy is ready!

https://toys-pr-31.somehats.workers.dev

Built from e85ee1f

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