Hey there StackOverflow community ๐. I'm implementing a web app which brings out all the possible information of a Discord user. Currently in the backend of my project I use express | passport | passport-discord (I am also following a tutorial on YouTube). The relevant code is
strategies/discord.js
const DiscordStrategy = require('passport-discord').Strategy;
const passport = require('passport');
const config = require('config');
var scopes = ['identify', 'email', 'guilds'];
passport.use(new DiscordStrategy({
clientID: config.get('discord.clientID'),
clientSecret: config.get('discord.clientSecret'),
callbackURL: config.get('discord.redirectURL'),
scope: scopes
}, (accessToken, refreshToken, profile, done) => {
console.log(profile.id);
console.log(profile.accent_color);
}));
routes/auth.js
const express = require('express');
const router = express.Router();
const passport = require('passport');
/* GET users listing. */
router.get('/', passport.authenticate('discord'));
router.get('/redirect', passport.authenticate('discord', {
failureRedirect: '/forbidden'
}), function(req, res) {
res.send(200) // Successful auth
});
module.exports = router;
config/default.json
{
"apiName": "Discord Profiler API",
"discord": {
"clientID": "xxx-xxx-xxx-xxx-xxx-xxx",
"clientSecret": "xxxxxxxxxxxxxxxxxxx",
"redirectURL": "localhost:9999/auth/redirect"
},
"port": 9999
}
The steps when debugging my project where:
/auth in my browserBut I have defined all the routes and test them to see if they work, and they all do. If your curious about the YouTube video I got this from this is the link
I know I'm late, but always make sure you add "http://" before the localhost and it should work!!
It must be http and not https since its a local address and can't have a SSL certificate
Can you check if you're missing the scheme part? it should be http://localhost:9999/auth/redirect