callback.html 파일 추가 및 OAuth 콜백 처리 로직 구현
package.json에 node-cron 및 node-fetch 의존성 추가 server.js에서 루트 경로에 대한 리다이렉트 로직 추가 .gitignore 파일 생성 public/index.html 및 callback/callback.html 파일 삭제
This commit is contained in:
parent
fdc903a3c1
commit
152f3ec045
6 changed files with 342 additions and 26 deletions
15
server.js
15
server.js
|
|
@ -3,9 +3,20 @@ const app = express();
|
|||
const path = require("path");
|
||||
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` +
|
||||
`&scope=email%20profile`;
|
||||
res.redirect(authUrl);
|
||||
});
|
||||
|
||||
// Access Token 수신용 엔드포인트
|
||||
app.get("/token", async (req, res) => {
|
||||
const token = req.query.access_token;
|
||||
|
|
@ -32,7 +43,7 @@ app.get("/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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue