From a6418e82bf40b46e1d703d876a809ee469892fa7 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Sat, 7 May 2022 16:39:01 +0200 Subject: [PATCH] Fix filepath --- src/getToken.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/getToken.js b/src/getToken.js index 51875ac..96113bd 100644 --- a/src/getToken.js +++ b/src/getToken.js @@ -14,7 +14,8 @@ const port = 8080; let state = "code"; // Read and parse JSON. There is no __dirname for modules -const secrets = JSON.parse(readFileSync(`${dirname(fileURLToPath(import.meta.url))}/../secrets.json`, "utf8")); +const secretsFile = `${dirname(fileURLToPath(import.meta.url))}/../secrets.json`; +const secrets = JSON.parse(readFileSync(secretsFile, "utf8")); // Express route that prints request body and query parameters app.use("/", (req, res) => { @@ -64,7 +65,7 @@ async function getToken(googleResponse) { console.log("Got the token!"); console.log("Writing token to secrets..."); secrets.refreshToken = data.refresh_token; - writeFileSync("./secrets.json", JSON.stringify(secrets)); + writeFileSync(secretsFile, JSON.stringify(secrets, null, 2)); console.log("Done!"); server.close();