Handle expired Google OAuth tokens gracefully by falling back to downloadable CSV spreadsheets

This commit is contained in:
2026-07-23 12:01:52 -04:00
parent d17d8a8e07
commit 65ec2ab580
2 changed files with 50 additions and 46 deletions
+1 -1
View File
@@ -1 +1 @@
240356 249378
+4
View File
@@ -585,6 +585,7 @@ app.post("/api/workspace/sheets/export", async (req, res) => {
const token = accessToken || req.headers.authorization?.replace("Bearer ", ""); const token = accessToken || req.headers.authorization?.replace("Bearer ", "");
if (token) { if (token) {
try {
const authClient = getOAuth2Client(token); const authClient = getOAuth2Client(token);
const sheets = google.sheets({ version: "v4", auth: authClient }); const sheets = google.sheets({ version: "v4", auth: authClient });
@@ -636,6 +637,9 @@ app.post("/api/workspace/sheets/export", async (req, res) => {
spreadsheetUrl, spreadsheetUrl,
message: `Successfully created Google Sheet with ${rows.length} records!` message: `Successfully created Google Sheet with ${rows.length} records!`
}); });
} catch (authErr: any) {
console.warn("Live Google API Token Expired/Unauthenticated. Falling back to downloadable CSV...", authErr.message);
}
} }
// Local CSV export generator when running without live Google OAuth access token // Local CSV export generator when running without live Google OAuth access token