npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@schybo-quizzing/react-oauth-discord

v1.1.7

Published

OAuth2 Enabled Button for Discord Login

Downloads

37

Readme

react-oauth-discord

Discord OAuth2 React Button built for Schybo Quizzing

Sign users in automatically when they return to your site on any device or browser, supports both the Authorization and Implicit flow

Install

$ npm install @schybo-quizzing/react-oauth-discord@latest

# or

$ yarn add @schybo-quizzing/react-oauth-discord@latest

button

Demo & How to use to fetch user details

Storybook

User authorization for Discord APIs (with custom button)

OAuth 2.0 implicit and authorization code flows for web apps

OAuth2 enables application developers to build applications that utilize authentication and data from the Discord API. Within Discord, there are multiple types of OAuth2 authentication. We support the authorization code grant, the implicit grant, client credentials, and some modified special-for-Discord flows for Bots and Webhooks.

How to use

  1. Get your Discord API client ID

https://discord.com/developers/applications > Application > OAuth2

Key Point: Add both http://localhost and http://localhost:<port_number> to the Authorized JavaScript origins box for local tests or development.

  1. Import Discord Button

Sign In With Google

import { DiscordLogin } from '@schybo-quizzing/react-oauth-discord'

<DiscordLogin
  discordClientId={DISCORD_CLIENT_ID}
  redirectUri={DISCORD_REDIRECT_URI}
  debug={true}
  backgroundColor={backgroundColor}
  size={size}
  label={label}
  newTab={newTab}
  props={props}>
<DiscordLogin>

Implicit flow

import { DiscordLogin } from '@schybo-quizzing/react-oauth-discord'

const login = () => {
  const params = new Proxy(new URLSearchParams(window.location.search), {
    get: (searchParams, prop) => searchParams.get(prop),
  });
  let value = params.code;
}

<DiscordLogin
  discordClientId={DISCORD_CLIENT_ID}
  redirectUri={DISCORD_REDIRECT_URI}
  debug={true}
  backgroundColor={backgroundColor}
  size={size}
  label={label}
  newTab={newTab}
  props={props}
  onclick={login}>
<DiscordLogin>

API

| Required | Prop | Type | Description | | :------: | --------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------ | | ✓ | discordClientId | string | Your Discord Client Id. Find yours at: https://discord.com/developers/applications > Application > OAuth2 | | ✓ | redirectUri | function | redirect Url after oAuth success or failure. See below for more information | | | debug | boolean | Provides helpful console debugging statements | | | backgroundColor | string | Background color of button | | | size | large | medium | small | Button size | | | label | string | Button contents. Default: Sign in with Discord | | | scopes | [string] | String array of scopes you need access to. Default: ['identify', 'email']. See below for more information. | | | responseType | string | Response type wanted from Discord oAuth. Default: code | | | newTab | boolean | Whether to open the oAuth box in a new tab | | | onclick | function | Optional click handler | | | buttonClasses | string | Optional extra classes to apply to the button | | | props | JSON | Optional extra props | | |

redirectUri

URL to redirect too after success or failure of user auth. Will attach discord code to be used in follow up api requests as the query parameter code. Has to match one of the URLs under https://discord.com/developers/applications > Application > OAuth2. If doing server auth Authorization flow, redirect to your server endpoint handling the rest of the login. Otherwise you can redirect to your and handle there

scopes

String array of scopes you need access to. Identify should always be applied, and if you're doing the Authorization flow you'll probably need identify as well. Default is ['identify', 'email']