passport-discord-advanced
v1.0.2
Published
**<h3>passport-discord-advanced</h3>** <br>
Downloads
3
Readme
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" /*Any others*/],
redirect_uri: "<Your url>/callback",
token: "The bot token", //Optional
});
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); //The authed user's data
console.log(user);
});
Add user to Guild
await passport.joinUser({
guild_id: "The guild id",
access_token: "The access_token", //Pass The access token
});//return GuildMember Object
Refresh Token
const refreshed_object = await passport.refresh(auth.refresh_token);//return new object with access_token and refresh_token
Contributors 📘
Made with ♥ and JavaScript By NithishCodez