Skip to content

simov/guardian

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grant img-npm-version

grant is build on top of mashape / guardian

providers live demo

amazon asana bitly box digitalocean dropbox
facebook flickr foursquare github google heroku
imgur instagram linkedin live mailchimp openstreetmap
paypal slack soundcloud stackexchange stocktwits stripe
trello tumblr twitch twitter vimeo yahoo

usage

var express = require('express');
var Grant = require('grant');

var grant = new Grant({
  server: require('./config/server.json'),
  credentials: require('./config/credentials.json'),
  options: require('./config/options.json')
});

var app = express();
// mount grant
app.use(grant);
// app server middlewares
app.use(cookieParser());
app.use(session());

reserved routes for grant

/connect/:provider
/step/:number
/connect/:provider/callback/

configuration

  • example/config/server.json - application server configuration required

    • host - application server host localhost:3000 | mydomain.com
    • port - application server port 3000
    • protocol - application server protocol http | https
    • callback - global final callback / | /done | /callback
  • example/config/credentials.json - oauth application credentials required

    • key - consumer_key for OAuth1 or client_id for OAuth2
    • secret - consumer_secret for OAuth1 or client_secret for OAuth2
  • example/config/options.json - oauth application options optional

    • scope - "scope1,scope2" or ["scope1","scope2"]
    • headers - {"User-Agent": "Grant"}
    • callback - final callback for this provider it must be different than the reserved routes for grant

flow

  1. register application on your provider's web site
  • if your provider requires absolute redirect url, then it should look like this (example for github) http://mydomain.com/connect/github/callback
  • otherwise http://mydomain.com should be enough
  1. set up your application callback in server.json this is the final callback when the OAuth flow is done and this must be something different than the reserved routes for grant
  2. optionally set specific callback for your provider in options.json instead of using the global one specified in server.json

license

MIT

About

Authentication Middleware for Express

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%