Proxy Google Docs List <2025>

// ------- OAuth2 (interactive) ------- const oauthCreds = JSON.parse(await readFile(oauthPath, "utf8")); const client_id, client_secret, redirect_uris = oauthCreds.installed

const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); Proxy Google Docs List

const app = express(); const PORT = process.env.PORT || 3000; // ------- OAuth2 (interactive) ------- const oauthCreds =

const docs = response.data.files.map((f) => ( id: f.id, name: f.name, createdTime: f.createdTime, modifiedTime: f.modifiedTime, owner: f.owners?.[0]?.displayName ?? "unknown" )); const __dirname = path.dirname(__filename)

// ------- Service‑account (no user interaction) ------- try const saKey = await readFile(saPath, "utf8"); const auth = new google.auth.GoogleAuth( credentials: JSON.parse(saKey), scopes: ["https://www.googleapis.com/auth/drive.readonly"] ); console.log("🔑 Using Service‑Account credentials"); return auth.getClient(); catch (e) console.warn("⚠️ Service‑account not found or invalid – falling back to OAuth2");

res.json( count: docs.length, docs ); catch (err) console.error("❌ Error while listing Docs:", err); res.status(500).json( error: "Failed to fetch Google Docs list", details: err.message ); );

// ────────────────────────────────────────────────────────────── // 1️⃣ Helper: create an authenticated Google API client // ────────────────────────────────────────────────────────────── async function getAuthClient() path.join(__dirname, "oauth-client.json");

0:00 0:00
music-hit Самые популярные песни