Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
Combine 2 codes in JS for oauth2

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);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!