Skip to content

NeutronX-dev/discord-auth.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-auth.js

Discord OAuth2 Made Simple

By NeutronX

Contents

Area Quick Description
Get Started Set-up discord-auth.js.
Integrating with Express Set-up with Express.

Get Started

First, construct the class, by writing:

const discord_auth_js = require('discord-auth.js');
const discord_auth = new discord_auth_js(lient_id, client_secret, callback_url);

Integrating with Express

First make sure you have the application set-up, and with it's redirect towards your app. then you can include the following in your code:

const discord_auth_js = require('discord-auth.js');
const discord_auth = new discord_auth_js(client_id, client_secret, callback_url);
app.get('/discord', (req, res) => {
    if(req.query.code){
        discord_auth.getUser(req.query.code).then((user) => {
            res.send(JSON.stringify(user));
        }).catch(error => {
            res.send(error.message);
        });
    } else {
        res.send("Did not recieve Code");
    }
});

About

Discord OAuth2 Made Simple.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published