2.1.4-0 • Published 1 year ago

discord-oauth2-utils v2.1.4-0

Weekly downloads
-
License
MIT license
Repository
github
Last release
1 year ago

npm:
https://www.npmjs.com/package/discord-oauth2-utils

Discord-oauth2-utils | The newer universal module for work with Discord API

npm module for working with Discord OAuth2

npm install discord-oauth2-utils

Check discord OAuth2 documentation: https://discord.com/developers/docs/topics/oauth2

Installing

npm install discord-oauth2-utils

OAuth2. Main interface

const OAuth2 = require("discord-oauth2-utils");

Expets one param — options:

Options

Request options:

clientId: BigInt | string; // Your OAuth2 client id. 

clientSecret: string; // Your OAuth2 client secret.

redirectURI: URL; // Redirect to page with presented URL.

scopes: Array<string> = ["identify"]; // List of scopes

responseType: "code" | "token" = "code";
const options = { clientId, clientSecret, ..., responseType };
const oauth2 = new OAuth2(options);

Methods

getLink(): URL

Returns URL like format:
https://discord.com/api/oauth2/authorize?client_id=&redirect_uri=&response_type=&scope=

getOAuth2Data(code): OAuth2Data

code — you can get code after user authorization and he redirect. Code will become part of the URL address as hash.

Returns OAuth2Data.

fetchUser(token): User

token — you can get token after user authorization and he redirect. access_token will become part of the URL address as query.

Returns User


Secondary interfaces

OAuth2Data

Corresponds https://discord.com/developers/docs/resources/user#get-current-user-guilds.

User

Object with {user: user, guilds?: Array}
user Corresponds https://discord.com/developers/docs/resources/user.
guild Corresponds https://discord.com/developers/docs/resources/user#get-current-user-guilds.

2.1.1-8

1 year ago

2.1.1-7

1 year ago

2.1.1-9

1 year ago

2.1.3-0

1 year ago

2.1.2-0

1 year ago

2.1.0

1 year ago

2.1.4-0

1 year ago

2.1.3-1

1 year ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago