0.2.74 • Published 3 years ago

express-oauth2-client v0.2.74

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Express OAuth2 Client

Installation

$ npm i express-oauth2-client

Basic Usage

import ExpressOAuth2Client from 'express-oauth2-client';
import express from 'express';
import session from 'express-session';
import config from 'config';

const app = express();

const oauth2Client = new ExpressOAuth2Client(app, {
  providers: config.get('oauth2'),
  homeUrl: '/home',
  prefix: '/oauth2',
});

app.use(
  session({
    secret: config.get('session.secret'),
    resave: false,
    saveUninitialized: true,
    cookie: { secure: false },
  })
);

app.use(oauth2Client.initialize());
app.use(oauth2Client.getLoggingMiddleware());
// add your routes here

app.listen(8000, () => {
  console.log('Server started on port: 8000');
});

Providers config object structure

{
  "github": {
    "clientId": "",
    "clientSecret": "",
    "scopes": ["user", "repo"]
  },
  "twitter": {
    "clientId": "",
    "clientSecret": "",
    "scopes": ["profile", "email"]
  },
  "google": {
    "clientId": "",
    "clientSecret": "",
    "scopes": ["profile", "email"]
  }
}

Registering Callbacks

This package has handlers set up for callback on the url '/{prefix}/callback/{provider}' So for example, if you set the prefix in the options as '/oauth2' and the provider is twitter. Then the callback url that you need to register on twitter's developer website is '/oauth2/callback/twitter'

Supported Providers

  • Github
  • Google
  • Twitter
0.2.74

3 years ago

0.2.73

3 years ago

0.2.72

3 years ago

0.2.71

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago