I wanted to make website discord oauth2, but when I tested I got an error {error: 'invalid_client'}. I was searching everywhere and nothing helped. Can you please tell me how to use Discord OAuth2.
I am using Node.JS, Express, Request
if(!req.query.code)
return res.redirect("/")
const discordTokenData = await request.post({
url: "https://discord.com/api/v9/oauth2/token",
qs: {
"client_id": client_id,
"client_secret": client_secret,
"grant_type": "authorization_code",
"code": req.query.code,
"redirect_uri": "http://localhost:3000/login",
"scope": "identify email guilds guilds.join"
},
headers: { "Content-Type": "application/x-www-form-urlencoded" },
}).catch((err) => console.log(err))
if(!discordTokenData)return console.log("err")
return res.send(discordTokenData.body)