I want to add discord login to my website, and I found this passport-discord package that seems to be the most popular way of doing so. However, I do not understand how I am supposed to use it, as I have little-to-no experience in NodeJS.
My goal is to have a Login button that uses Discord authentication.
My understanding is that I need to instantiate these variables
var passport = require('passport')
var DiscordStrategy = require('passport-discord').Strategy;
var scopes = ['identify', 'email', 'guilds', 'guilds.join'];
passport.use(new DiscordStrategy({
clientID: 'id',
clientSecret: 'secret',
callbackURL: 'callbackURL',
scope: scopes
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ discordId: profile.id }, function(err, user) {
return cb(err, user);
});
}));
And then somehow perform the get request (?) and I should receive a token to then use in the Discord API.
app.get('/auth/discord', passport.authenticate('discord'));
Am I right? How can I embed this into a login button?