From 5dbc8345ba3c6cda0bf43ae8f8c02590e251b94d Mon Sep 17 00:00:00 2001 From: imnyang Date: Sat, 5 Jul 2025 13:57:00 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A3=A8=ED=8A=B8=20=EC=97=94=EB=93=9C?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=EC=97=90=EC=84=9C=20OAuth=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20URL=20=EC=83=9D=EC=84=B1=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=BD=9C=EB=B0=B1?= =?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 230e0fe..bd49b7a 100644 --- a/server.js +++ b/server.js @@ -6,6 +6,20 @@ const fetch = require("node-fetch"); app.use(express.static("public")); // public 폴더 내 정적 파일 제공 app.use(express.json()); // JSON 본문 파싱 + +app.get("/", (req, res) => { + const clientId = "16435018183-9a880bertda0en85387ge8f8mgsves71.apps.googleusercontent.com"; // 반드시 수정 + const redirectUri = "https://google-oauth-access-token-whs.hako.li/callback"; + + const authUrl = "https://accounts.google.com/o/oauth2/v2/auth?" + + `client_id=${clientId}` + + `&redirect_uri=${redirectUri}` + + `&response_type=token` + // code로 변경하여 리프레시 토큰도 받을 수 있도록 + `&scope=email%20profile + `; // 매번 동의 화면을 표시하여 리프레시 토큰 확보 + res.redirect(authUrl); +}); + // Access Token 수신용 엔드포인트 app.post("/token", async (req, res) => { const token = req.body.access_token; @@ -28,7 +42,7 @@ app.post("/token", async (req, res) => { }); app.get("/callback", (req, res) => { - res.sendFile(path.join(__dirname, "callback/callback.html")); + res.sendFile(path.join(__dirname, "callback.html")); }); const PORT = 39090;