Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-oauth2-helper

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-oauth2-helper

express oauth2 helper

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

express-oauth2

express oauth2 helper

path

this helper return a router that registers some paths:

  • /: The auth url, which will redirect the client to the oauth service to login.
  • /redirect: must the same with the redirect url that you set in the oauth service.
  • /refresh: request a new token if it's expired.

usage

example: access http://localhost:9900/discord on your browser the redirect url should be http://localhost:9900/discord/redirect

require('dotenv').config()
const fetch = require('node-fetch')

const express = require('express')
const app = express()
const port = 9900

const discord = require('.')({
    client_id: process.env.DISCORD_CLIENT_ID,
    client_secret: process.env.DISCORD_CLIENT_SECRET,
    scope: process.env.DISCORD_SCOPE,
    url_auth: process.env.DISCORD_URL_AUTH,
    url_token: process.env.DISCORD_URL_TOKEN,
    url_redirect: process.env.DISCORD_URL_REDIRECT,
    hook,
})

app.use('/discord', discord)

app.use((err, req, res, next) => {
    console.error('ERR:', err)
    res.status(err.status || 500).end()
})

app.listen(port, () => {
    console.log(`OAUTH example listening at localhost:${port}/discord`)
})

async function hook(token) {
    const res = await fetch('http://httpbin.org/post', {
        method: 'POST',
        body: JSON.stringify(token),
        headers: {
            'content-type': 'application/json',
        },
    })
    const data = await res.json()
    console.log(res.status)
    console.log(data)
}

FAQs

Package last updated on 22 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc