From f6a2759e7e29094d1a51a63439cc49aba2452644 Mon Sep 17 00:00:00 2001 From: JuLi0n21 Date: Wed, 10 Jan 2024 02:37:41 +0100 Subject: [PATCH] add custome callback port --- public/index.html | 2 +- server.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 29e050d..26f2383 100644 --- a/public/index.html +++ b/public/index.html @@ -7,6 +7,6 @@

Hey u shouldnt be here!

- Login with Osu! + Login with Osu! \ No newline at end of file diff --git a/server.js b/server.js index 3681360..ac908bc 100644 --- a/server.js +++ b/server.js @@ -18,6 +18,10 @@ app.get('/', (req, res) => { }); app.get('/authorize', (req, res) => { + + if(req.query.port != null){ + + const authorizationUrl = 'https://osu.ppy.sh/oauth/authorize'; const redirectUri = `https://${process.env.VERCEL_URL}/callback`; const client_id = process.env.CLIENT_ID; @@ -25,13 +29,16 @@ app.get('/authorize', (req, res) => { const scope = 'public identify'; const state = 'Randomstate'; - res.redirect(`${authorizationUrl}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=${response_type}&scope=${scope}`); + res.redirect(`${authorizationUrl}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=${response_type}&scope=${scope}&state=${req.query.port}`); + } else { + res.json({ error: "callback port needs to be defined"}) + } }); app.get('/callback', async (req, res) => { const authorizationCode = req.query.code; - console.log(authorizationCode) + console.log(req.query.state) try { const tokenEndpoint = 'https://osu.ppy.sh/oauth/token'; const requestBody = new URLSearchParams({