Просмотр исходного кода

feat: Add credential validation for Google Drive API initialization

Taylor Wilsdon (aider) 4 месяцев назад
Родитель
Сommit
a0ba5974f6
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      src/lib/utils/google-drive-picker.ts

+ 8 - 0
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;
     }