I wanted to a console output for my oauth2 app to provide me both access code and the user details as well. I found 2 different codes for them. I want to know is it possible for me to combine both of them? If yes how to I combine them.
Here's the first code for access code:
const express = require('express');
const { port } = require('./config.json');
const DiscordOauth2 = require("discord-oauth2");
const oauth = new DiscordOauth2();
const app = express();
app.get('/', (request, response) => {
console.log(`The access code is: ${request.query.code}`)
;
return response.sendFile('index.html', { root: '.' });
});
app.listen(port, () => console.log(`App listening at http://localhost:${port}`));
Here's another code to gather user details:
const DiscordOauth2 = require("discord-oauth2");
const oauth = new DiscordOauth2();
const access_token = "6qrZcUqja7812RVdnEKjpzOL4CvHBFG";
oauth.getUser(access_token).then(console.log);