2024-09-17 20:38:32 +05:30
|
|
|
import { Router } from 'express';;
|
|
|
|
|
import { google, sheets_v4 } from "googleapis";
|
2024-09-17 20:39:42 +05:30
|
|
|
import fs from 'fs';
|
|
|
|
|
import path from 'path';
|
2024-09-17 20:38:32 +05:30
|
|
|
|
|
|
|
|
export const router = Router()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/upload-credentials', (req, res) => {
|
|
|
|
|
const credentials = req.body.credentials;
|
|
|
|
|
|
|
|
|
|
if (!credentials) {
|
|
|
|
|
return res.status(400).json({ message: 'Credentials are required.' });
|
2024-09-17 20:39:42 +05:30
|
|
|
}
|
|
|
|
|
// 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.' });
|
|
|
|
|
});
|