mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🔑 feat: Set Google Service Key File Path (#8130)
This commit is contained in:
parent
3f3cfefc52
commit
20100e120b
3 changed files with 47 additions and 14 deletions
|
|
@ -439,15 +439,20 @@ async function loadGoogleAuthConfig(): Promise<{
|
|||
serviceAccount: GoogleServiceAccount;
|
||||
accessToken: string;
|
||||
}> {
|
||||
/** Path from current file to project root auth.json */
|
||||
const authJsonPath = path.join(__dirname, '..', '..', '..', 'api', 'data', 'auth.json');
|
||||
/** Path from environment variable or default location */
|
||||
const serviceKeyPath =
|
||||
process.env.GOOGLE_SERVICE_KEY_FILE_PATH ||
|
||||
path.join(__dirname, '..', '..', '..', 'api', 'data', 'auth.json');
|
||||
const absolutePath = path.isAbsolute(serviceKeyPath)
|
||||
? serviceKeyPath
|
||||
: path.resolve(serviceKeyPath);
|
||||
|
||||
let serviceKey: GoogleServiceAccount;
|
||||
try {
|
||||
const authJsonContent = fs.readFileSync(authJsonPath, 'utf8');
|
||||
const authJsonContent = fs.readFileSync(absolutePath, 'utf8');
|
||||
serviceKey = JSON.parse(authJsonContent) as GoogleServiceAccount;
|
||||
} catch {
|
||||
throw new Error(`Google service account not found at ${authJsonPath}`);
|
||||
throw new Error(`Google service account not found at ${absolutePath}`);
|
||||
}
|
||||
|
||||
if (!serviceKey.client_email || !serviceKey.private_key || !serviceKey.project_id) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue