mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-18 15:35:55 +08:00
fix: Improve Google Drive API credentials validation and error handling
This commit is contained in:
parent
a0ba5974f6
commit
c3d631ca98
@ -499,16 +499,15 @@
|
|||||||
}}
|
}}
|
||||||
uploadGoogleDriveHandler={async () => {
|
uploadGoogleDriveHandler={async () => {
|
||||||
try {
|
try {
|
||||||
if (!import.meta.env.VITE_GOOGLE_API_KEY || !import.meta.env.VITE_GOOGLE_CLIENT_ID) {
|
|
||||||
throw new Error('Google Drive API credentials not configured');
|
|
||||||
}
|
|
||||||
const fileData = await createPicker();
|
const fileData = await createPicker();
|
||||||
if (fileData) {
|
if (fileData) {
|
||||||
dispatch('upload', { type: 'google-drive', data: fileData });
|
dispatch('upload', { type: 'google-drive', data: fileData });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Google Drive Error:', error);
|
console.error('Google Drive Error:', error);
|
||||||
toast.error('Error accessing Google Drive: ' + error.message);
|
toast.error($i18n.t('Error accessing Google Drive: {{error}}', {
|
||||||
|
error: error.message
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onClose={async () => {
|
onClose={async () => {
|
||||||
|
@ -6,7 +6,10 @@ const SCOPE = ['https://www.googleapis.com/auth/drive.readonly'];
|
|||||||
// Validate required credentials
|
// Validate required credentials
|
||||||
const validateCredentials = () => {
|
const validateCredentials = () => {
|
||||||
if (!API_KEY || !CLIENT_ID) {
|
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.');
|
throw new Error('Google Drive API credentials not configured');
|
||||||
|
}
|
||||||
|
if (API_KEY === 'your-api-key' || CLIENT_ID === 'your-client-id') {
|
||||||
|
throw new Error('Please configure valid Google Drive API credentials');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user