Implementation of Discord OAuth2 authentication in Node.js/Typescript to obtain authenticated user information.
- Create an Discord application and define a name:
- Set the redirect URL and save changes:
- Clone this project to your computer:
git clone https://github.com/ArturMiguel/discord-oauth2
- Install the dependencies:
npm install
- Create an
.env
file with the CLIENT ID and CLIENT SECRET from your Discord application:
CLIENT_ID=
CLIENT_SECRET=
- To run in development mode, type:
npm run dev
- Access
http://localhost:3000/api/discord/auth
- Clicking in "Authorize", will return a json with the authenticated user's information: