From 84a4afa7fc7ef6b55a3f3debb88bbd407fe5545e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 17 Sep 2024 20:39:42 +0530 Subject: [PATCH] feat: upload service account credentials --- server/src/routes/integration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/routes/integration.ts b/server/src/routes/integration.ts index 70e3425e..07d04bcf 100644 --- a/server/src/routes/integration.ts +++ b/server/src/routes/integration.ts @@ -1,5 +1,7 @@ import { Router } from 'express';; import { google, sheets_v4 } from "googleapis"; +import fs from 'fs'; +import path from 'path'; export const router = Router() @@ -9,4 +11,10 @@ router.post('/upload-credentials', (req, res) => { if (!credentials) { return res.status(400).json({ message: 'Credentials are required.' }); - } \ No newline at end of file + } + // Todo: Store the credentials in a secure place (for test, we store them locally) + const storedCredentialsPath = path.join(__dirname, 'service_account_credentials.json'); + fs.writeFileSync(storedCredentialsPath, JSON.stringify(credentials)); + + res.status(200).json({ message: 'Service Account credentials saved successfully.' }); +}); \ No newline at end of file