feat: get spreadsheets from drive

This commit is contained in:
karishmas6
2024-09-15 19:16:23 +05:30
parent 13ecfae2d6
commit a9868f255a

View File

@@ -35,4 +35,19 @@ router.get('/auth/google/callback', async (req, res) => {
console.error('Error during authentication:', error);
res.status(500).send('Authentication failed');
}
});
});
router.get('/sheets', async (req, res) => {
try {
const drive = google.drive({ version: 'v3', auth: oauth2Client });
const response = await drive.files.list({
q: "mimeType='application/vnd.google-apps.spreadsheet'",
fields: 'files(id, name)'
});
res.json(response.data.files);
} catch (error) {
console.error('Error listing sheets:', error);
res.status(500).send('Failed to list sheets');
}
});