/discord-oauth2

Simple implementation of Discord OAuth2 authentication.

Primary LanguageTypeScriptMIT LicenseMIT

Discord OAuth2

Implementation of Discord OAuth2 authentication in Node.js/Typescript to obtain authenticated user information.


Configuration and Installation

  1. Create an Discord application and define a name:

  1. Set the redirect URL and save changes:

  1. Clone this project to your computer:
git clone https://github.com/ArturMiguel/discord-oauth2
  1. Install the dependencies:
npm install
  1. Create an .env file with the CLIENT ID and CLIENT SECRET from your Discord application:
CLIENT_ID=
CLIENT_SECRET=


Running

  1. To run in development mode, type:
npm run dev
  1. Access http://localhost:3000/api/discord/auth

  1. Clicking in "Authorize", will return a json with the authenticated user's information: