Narwhals Prolong Mischief

    auth-discord

    1.1.5 • Public • Published

    Auth-Discord for Nodejs app

    Attention, the "secret_id" may be visible, please use this module with caution.

    Demo

    How to use it

    Note: you need to add http://localhost:3000 Here in to allow url redirection in your application

    const {login} = require("auth-discord");
    // ...
     
    // Login and get access_token:
    login("CLIENT ID", "CLIENT SECRET", "identify email").then(resp => console.log(resp.access_token))
     

    Login return :

    { 
        "access_token": "an access token",
        "token_type": "Bearer",
        "expires_in": 604800,
        "refresh_token": "a refresh token",
        "scope": "identify" 
    }

    GetUserInfo :

    Exemple Return Result :

    login("CLIENT ID", "CLIENT SECRET", "identify").then(resp => GetUserInfo(resp.access_token).then(resp => console.log(resp)))
    {
      "id": "708717385456156716",
      "username": "AndroneDev",
      "avatar": "b6a852c697c339fdfd114c2164213829",
      "discriminator": "8964",
      "public_flags": 131328,
      "flags": 131328,
      "verified": true,
      "locale": "fr",
      "mfa_enabled": true
    }

    Exemples

    const {login, GetUserInfo} = require("auth-discord");
     
    // Method 1
     
    login("CLIENT ID", "CLIENT SECRET", "identify email").then(resp => console.log(resp.access_token))
     
     
     
    // Method 2
    async function mylogin(){
        let resp = await login("CLIENT ID", "CLIENT SECRET", "identify email")
        console.log(resp.access_token)
    }
    mylogin()
     
     
     
    // GetUserInfo
     
    GetUserInfo(access_token).then(resp => console.log(resp))
     
    // login and GetUserInfo
     
    login("CLIENT ID", "CLIENT SECRET", "identify").then(resp => GetUserInfo(resp.access_token).then(resp => console.log(resp)))
     
     

    Developed by AndroneDev

    My WebSite | My Discord

    Install

    npm i auth-discord

    DownloadsWeekly Downloads

    3

    Version

    1.1.5

    License

    ISC

    Unpacked Size

    4.99 kB

    Total Files

    3

    Last publish

    Collaborators

    • andronedev