passport-discord-advanced
what is passport-discord-advanced?
passport discord advanced is a Express middleware for discord OAuth2 and OAuth wrapper with essential functions to get you started with discord's OAuth applications
Installation:
npm i passport-discord-advanced
Basic Usage
const passport_discord = require("passport-discord-advanced");
const passport = new passport_discord({
client_id: "Your client id",
client_secret: "Your client secret",
scopes: ["identify", "guilds.join" ],
redirect_uri: "<Your url>/callback",
token: "The bot token",
});
const express = require("express");
const app = express();
app.get("/", passport.authenticate());
app.get("/callback", async (req, res) => {
const auth = await passport.authenticateUser(req);
const user = await passport.getUserData(auth.access_token);
console.log(user);
});
Add user to Guild
await passport.joinUser({
guild_id: "The guild id",
access_token: "The access_token",
});
Refresh Token
const refreshed_object = await passport.refresh(auth.refresh_token);
Contributors 📘
Made with ♥ and JavaScript By NithishCodez