fix: ts errors
This commit is contained in:
@@ -25,17 +25,21 @@ router.get('/auth/google', (req, res) => {
|
|||||||
|
|
||||||
// Callback route for Google OAuth 2.0
|
// Callback route for Google OAuth 2.0
|
||||||
router.get('/auth/google/callback', async (req, res) => {
|
router.get('/auth/google/callback', async (req, res) => {
|
||||||
const { code } = req.query;
|
const code = req.query.code;
|
||||||
try {
|
if (typeof code !== 'string') {
|
||||||
const { tokens } = await oauth2Client.getToken(code);
|
res.status(400).send('Invalid authorization code');
|
||||||
oauth2Client.setCredentials(tokens);
|
return;
|
||||||
// Store tokens securely (e.g., in a database)
|
|
||||||
res.send('Authentication successful');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error during authentication:', error);
|
|
||||||
res.status(500).send('Authentication failed');
|
|
||||||
}
|
}
|
||||||
});
|
try {
|
||||||
|
const { tokens } = await oauth2Client.getToken(code);
|
||||||
|
oauth2Client.setCredentials(tokens);
|
||||||
|
// Store tokens securely (e.g., in a database)
|
||||||
|
res.send('Authentication successful');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during authentication:', error);
|
||||||
|
res.status(500).send('Authentication failed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/sheets', async (req, res) => {
|
router.get('/sheets', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user