express-oauth-any

1.0.6 • Public • Published

Express OAuth Any

OAuth implementations for most popular OAuth providers

Supported OAuth Providers

Implemented :

  • Twitter
  • Google
  • GitHub

Coming soon (Help requested) :

  • Facebook
  • Microsoft
  • Apple
  • Amazon
  • LinkedIn

Installation

Dependencies

express and express-session

Install

$ npm install express-oauth-any

Add the following to app.js

  var { registerOauth } = require('express-oauth-any');
  app.use(session({ secret: "yoursecret"}))
  registerOauth(app, options);

Options

Options should include the platforms for which you need oauth enabled

  options = {
      twitter: {
          key: "YOUR CONSUMER KEY", 
          secret: "YOUR CONSUMER SECRET"
      }
  }

Usage

Once installed, call the following url to invoke the login process <a href="/oauth-any/twitter/login?state=/profile"> Login with Twitter </a>

Once the login is successful, user will be redirected to the url determined by state and login information will be available in req.session[PLATFORM], e.g. req.session.twitter

You can replace "twitter" with "google" in the above example for login using Google

Twitter

  options = {
      twitter: {
          key: "YOUR CONSUMER KEY", 
          secret: "YOUR CONSUMER SECRET"
      }
  }

Get your Consumer Key and Consumer Secret on developers.twitter.com

http://localhost:<PORT>/oauth-any/twitter/callback
https://yourdomainname.com/oauth-any/twitter/callback

Google

  options = {
      google: {
          key: "Your Client Id", 
          secret: "Your Client Secret"
      }
  }

Get your Consumer Key and Consumer Secret on https://console.cloud.google.com/apis/credential

Create an OAuth Client ID Set callback urls as

http://localhost:<PORT>/oauth-any/google/callback
https://yourdomainname.com/oauth-any/google/callback

GitHub

    options = {
      github: {
        key: "Your Client ID"
        secret: "Your Client Secret"
        scope: "Your Selected Scope"
      }
    }

Requested help

Please help me implement the various OAuth Providers listed here so that others don't have to

Readme

Keywords

none

Package Sidebar

Install

npm i express-oauth-any

Weekly Downloads

5

Version

1.0.6

License

ISC

Unpacked Size

8.21 kB

Total Files

6

Last publish

Collaborators

  • madhavanmalolan