I'm trying to make a basic Discord OAuth2 app, just with the identify
scope, in node.js/express. My code is:
const express = require('express');
const app = express();
const axios = require('axios');
app.get('/oauth-callback', async (req, res) => {
const code = req.query.code;
if(!code) return;
axios.post("https://discordapp.com/api/oauth2/token", `client_id=${client_id}&client_secret=${client_secret}&grant_type=client_credentials&code=${code}&redirect_uri=${redirect}&scope=identify`)
.then(async (response) => {
const access_token = response.data.access_token;
console.log(access_token);
const data = await axios.get("https://discordapp.com/api/users/@me", { headers: { "authorization":`Bearer ${access_token}` } })
res.send(data.data);
}).catch(e => console.log(`Error: ${e}`));
});
I added in the console.log(access_token);
and it logs an access token to the console perfectly fine. My problem is extremely bazarre, I am working on this project with a friend and he set up the application on the developer portal, so I login with my account, and when it does res.send(data.data);
, rather than my account's details, I see my friends accounts details. I'm guessing its because he created the discord application and set everything up, but I don't know how to fix it. Thanks!
question from:
https://stackoverflow.com/questions/65944053/discord-oauth2-always-returns-the-data-of-the-applications-owner 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…