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;