Handle expired Google OAuth tokens gracefully by falling back to downloadable CSV spreadsheets
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user