Skip to main content

Overview

Google Drive commands handle OAuth authentication, folder browsing, file indexing, and cloud streaming for media stored in Google Drive.

Authentication

connect_google_drive

Alias for gdrive_start_auth + gdrive_complete_auth. Start the OAuth flow.
#[tauri::command]
async fn gdrive_start_auth() -> Result<String, String>
OAuth Flow:
  1. gdrive_start_auth returns a Google OAuth URL and opens it in the default browser
  2. User authenticates with Google
  3. Backend server receives the code and redirects to localhost:42069 with tokens
  4. gdrive_complete_auth waits for this callback, stores tokens, and returns account info
authUrl
string
Google OAuth consent screen URL

gdrive_complete_auth

Complete OAuth authentication (waits for callback from browser).
#[tauri::command]
async fn gdrive_complete_auth(
    state: State<'_, AppState>,
) -> Result<gdrive::DriveAccountInfo, String>
DriveAccountInfo
object

disconnect_google_drive

Revoke OAuth tokens and disconnect.
#[tauri::command]
async fn gdrive_disconnect(
    state: State<'_, AppState>,
) -> Result<ApiResponse, String>

get_drive_account_info

Get current Google Drive account information.
#[tauri::command]
async fn gdrive_get_account_info(
    state: State<'_, AppState>,
) -> Result<gdrive::DriveAccountInfo, String>

gdrive_is_connected

Check if authenticated to Google Drive.
#[tauri::command]
async fn gdrive_is_connected(
    state: State<'_, AppState>,
) -> Result<bool, String>

Folder Management

scan_cloud_library

Alias for gdrive_scan_folder. Scan a Google Drive folder and index all video files.
#[tauri::command]
async fn gdrive_scan_folder(
    state: State<'_, AppState>,
    window: Window,
    folder_id: String,
    folder_name: String,
) -> Result<CloudIndexResult, String>
folder_id
string
required
Google Drive folder ID
folder_name
string
required
Folder name (for display/logging)
CloudIndexResult
object
Auto-Detection: The scanner parses filenames to detect:
  • Movies: Movie Title (2023).mkv
  • TV Shows: Show Name S01E05.mkv
It fetches metadata from TMDB and downloads posters automatically.

get_cloud_stream_url

Alias for gdrive_get_stream_url. Get a temporary streaming URL for a Google Drive file.
#[tauri::command]
async fn gdrive_get_stream_url(
    state: State<'_, AppState>,
    file_id: String,
) -> Result<(String, String), String>
file_id
string
required
Google Drive file ID
tuple
[string, string]
Returns [stream_url, access_token]
Streaming URLs expire after approximately 1 hour. Access tokens must be included in all video chunk requests.

delete_cloud_file

Alias for Google Drive file deletion (handled by delete_media_files command). See Library Management - delete_media_files

gdrive_list_folders

List folders in Google Drive.
#[tauri::command]
async fn gdrive_list_folders(
    state: State<'_, AppState>,
    parent_id: Option<String>,
) -> Result<Vec<gdrive::DriveItem>, String>
parent_id
string | null
Parent folder ID, or null for root

gdrive_list_video_files

List all video files in a folder.
#[tauri::command]
async fn gdrive_list_video_files(
    state: State<'_, AppState>,
    folder_id: String,
    recursive: bool,
) -> Result<Vec<gdrive::DriveItem>, String>
folder_id
string
required
Folder ID to scan
recursive
boolean
required
Whether to scan subfolders
Only returns files with video MIME types: video/mp4, video/x-matroska, video/webm, etc.

Change Detection

check_cloud_changes

Poll Google Drive for new or changed video files (uses Changes API).
#[tauri::command]
async fn check_cloud_changes(
    state: State<'_, AppState>,
    window: Window,
) -> Result<CloudIndexResult, String>
How it works:
  1. Stores a “changes token” after each poll
  2. On next poll, fetches only files that changed since the last token
  3. Automatically indexes new video files
  4. Sends desktop notifications for new content
  5. Much more efficient than re-scanning entire folders
StreamVault polls for changes every 5 seconds automatically in the background. You rarely need to call this manually.

Events

cloud-scan-complete

Emitted when a folder scan finishes.
import { listen } from '@tauri-apps/api/event';

await listen<{
  folder: string;
  indexed: number;
  skipped: number;
  movies: number;
  tv: number;
}>('cloud-scan-complete', (event) => {
  console.log(`Scan complete: ${event.payload.folder}`);
});

cloud-indexing-started

Emitted when change detection finds new files.
await listen<{ count: number }>('cloud-indexing-started', (event) => {
  console.log(`Indexing ${event.payload.count} new files...`);
});

Build docs developers (and LLMs) love