From a0ba5974f66e1e945478df3614bc6519def274a0 Mon Sep 17 00:00:00 2001 From: "Taylor Wilsdon (aider)" Date: Sun, 15 Dec 2024 16:54:19 -0500 Subject: [PATCH] feat: Add credential validation for Google Drive API initialization --- src/lib/utils/google-drive-picker.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/utils/google-drive-picker.ts b/src/lib/utils/google-drive-picker.ts index cfd030c20..62726bec8 100644 --- a/src/lib/utils/google-drive-picker.ts +++ b/src/lib/utils/google-drive-picker.ts @@ -3,6 +3,13 @@ const API_KEY = import.meta.env.VITE_GOOGLE_API_KEY; const CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID; const SCOPE = ['https://www.googleapis.com/auth/drive.readonly']; +// Validate required credentials +const validateCredentials = () => { + if (!API_KEY || !CLIENT_ID) { + throw new Error('Google Drive API credentials not configured. Please set VITE_GOOGLE_API_KEY and VITE_GOOGLE_CLIENT_ID environment variables.'); + } +}; + let pickerApiLoaded = false; let oauthToken: string | null = null; let initialized = false; @@ -65,6 +72,7 @@ export const getAuthToken = async () => { const initialize = async () => { if (!initialized) { + validateCredentials(); await Promise.all([loadGoogleDriveApi(), loadGoogleAuthApi()]); initialized = true; }