{"id":21062160,"url":"https://github.com/bioblaze/passport-discord.js","last_synced_at":"2026-04-25T11:32:32.788Z","repository":{"id":34904246,"uuid":"188468380","full_name":"Bioblaze/passport-discord.js","owner":"Bioblaze","description":"Passport strategy for authentication with Discord (discordapp.com)","archived":false,"fork":false,"pushed_at":"2023-01-03T22:39:42.000Z","size":1078,"stargazers_count":1,"open_issues_count":14,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-30T11:56:52.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bioblaze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-24T18:17:53.000Z","updated_at":"2020-10-18T16:06:45.000Z","dependencies_parsed_at":"2023-01-15T10:08:47.931Z","dependency_job_id":null,"html_url":"https://github.com/Bioblaze/passport-discord.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Bioblaze/passport-discord.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bioblaze%2Fpassport-discord.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bioblaze%2Fpassport-discord.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bioblaze%2Fpassport-discord.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bioblaze%2Fpassport-discord.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bioblaze","download_url":"https://codeload.github.com/Bioblaze/passport-discord.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bioblaze%2Fpassport-discord.js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259896112,"owners_count":22928325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T17:37:37.735Z","updated_at":"2026-04-25T11:32:32.737Z","avatar_url":"https://github.com/Bioblaze.png","language":"JavaScript","funding_links":["https://paypal.me/BioblazePayne"],"categories":[],"sub_categories":[],"readme":"# passport-discord.js\n\n![Build Status](https://img.shields.io/travis/Bioblaze/passport-discord.js.svg)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n![Downloads](https://img.shields.io/npm/dm/passport-discord.js.svg)\n![Downloads](https://img.shields.io/npm/dt/passport-discord.js.svg)\n![npm version](https://img.shields.io/npm/v/passport-discord.js.svg)\n![License](https://img.shields.io/npm/l/passport-discord.js.svg)\n\n![dependencies](https://img.shields.io/david/Bioblaze/passport-discord.js.svg)\n![dev dependencies](https://img.shields.io/david/dev/Bioblaze/passport-discord.js.svg)\n\n[![Code Climate](https://codeclimate.com/github/Bioblaze/passport-discord.js/badges/gpa.svg)](https://codeclimate.com/github/Bioblaze/passport-discord.js)\n[![Discord Chat](https://img.shields.io/discord/165374225320771586.svg)](https://discord.gg/T8uVhzU)  \n[![PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://paypal.me/BioblazePayne) \n\nDiscord is a trademark or registered trademark of Hammer \u0026 Chisel, Inc. in the U.S. and/or other countries. \"passport-discord.js\" is not operated by, sponsored by, or affiliated with Hammer \u0026 Chisel Inc. in any way.\n\n[Passport](http://passportjs.org/) strategies for authenticating with [Discord](https://discordapp.com/)\nusing OAuth 2.0 API.\n\nThis module lets you authenticate using Discord in your Node.js applications.\nBy plugging into Passport, Discord authentication can be easily and\nunobtrusively integrated into any application or framework that supports\n[Connect](http://www.senchalabs.org/connect/)-style middleware, including\n[Express](http://expressjs.com/).\n\n## Install\n```bash\n$ npm install passport-discord.js\n```\n## Usage of OAuth 2.0\n\n#### Configure Strategy\n\nThe Discord OAuth 2.0 authentication strategy authenticates users using a Discord\naccount and OAuth 2.0 tokens. The strategy requires a `verify` callback, which\naccepts these credentials and calls `done` providing a user, as well as\n`options` specifying a client ID, client secret, and callback URL.\n\n```javascript\nvar passport       = require(\"passport\");\nvar discordStrategy = require(\"passport-discord.js\").Strategy;\n\npassport.use(new discordStrategy({\n    clientID: DISCORD_CLIENT_ID,\n    clientSecret: DISCORD_CLIENT_SECRET,\n    callbackURL: \"http://127.0.0.1:3000/auth/discord/callback\",\n    scope: [\"guilds\", \"connections\", \"email\"]\n  },\n  function(accessToken, refreshToken, profile, done) {\n    //Handle Database Query Addition Here.\n  }\n));\n```\n\n#### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `\"discord.js\"` strategy, to\nauthenticate requests.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n```javascript\napp.get(\"/auth/discord\", passport.authenticate(\"discord.js\"));\napp.get(\"/auth/discord/callback\", passport.authenticate(\"discord.js\", { failureRedirect: \"/\" }), function(req, res) {\n    // Successful authentication, redirect home.\n    res.redirect(\"/\");\n});\n```\n\nThe request to this route should include a GET or POST data with the keys `access_token` from Discord.\n\n```\nGET /auth/discord?access_token=\u003cTOKEN\u003e\n```\n\n## Issues\n\nIf you receive a `401 Unauthorized` error, it is most likely because you have wrong access token or not yet specified any application permissions.\nOnce you refresh access token with new permissions, try to send this access token again.\n\n## Example\n\n```javascript\n#!/bin/env node\n\nrequire('dotenv').config();\n\nvar express = require('express');\nvar session = require('express-session');\nvar helmet = require('helmet');\nvar bodyParser = require('body-parser');\n\nvar passport = require('passport');\nvar refresh = require('passport-oauth2-refresh');\nvar _strategy = require('passport-discord.js').Strategy;\n\nvar app = express();\n\napp.use(session({\n  key: process.env.SESSION_KEY,\n  secret: process.env.SESSION_SECRET,\n  resave: true,\n  saveUninitialized: true,\n  cookie: {\n    secure: true\n  }\n}));\n\napp.use(helmet());\napp.use(bodyParser.urlencoded({ extended: true }));\napp.use(bodyParser.json());\n\npassport.serializeUser(function(u, d) {\n  d(null, u);\n});\npassport.deserializeUser(function(u, d) {\n  d(null, u);\n});\n\nvar DiscordStrategy = new _strategy({\n  clientID: process.env.DISCORD_ID,\n  clientSecret: process.env.DISCORD_SECRET,\n  callbackURL: \"http://127.0.0.1:3000/auth/discord/callback\",\n  scope: [\"guilds\", \"connections\", \"email\"]\n}, function(accesstoken, refreshToken, profile, done) {\n  console.log(profile);\n  return done(null, profile);\n});\n\npassport.use(DiscordStrategy);\nrefresh.use(DiscordStrategy);\n\napp.get('/', function(req, res) {\n  if (!req.session.user) {\n    res.redirect('/login');\n  } else {\n    res.send(`Hello ${req.session.user.username}`);\n  }\n});\n\napp.get('/login', passport.authenticate('discord.js'}));\napp.get('/auth/discord/callback', passport.authenticate('discord.js', { failureRedirect: '/' }), function(req, res) {\n  req.session.user = req.user;\n  console.log(req.user);\n  console.log(req.query);\n  res.redirect('/');\n});\napp.listen(process.env.SITE_PORT, process.env.SITE_HOST, function() {\n  console.log(`Express Started`);\n});\n\n```\n\nProjected Maintained by: Randolph Aarseth(Bioblaze Payne)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioblaze%2Fpassport-discord.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbioblaze%2Fpassport-discord.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbioblaze%2Fpassport-discord.js/lists"}