grant is build on top of mashape / guardian
providers live demo
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());
/connect/:provider
/step/:number
/connect/:provider/callback/
-
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
- host - application server host
-
example/config/credentials.json - oauth application credentials
required
- key -
consumer_key
for OAuth1 orclient_id
for OAuth2 - secret -
consumer_secret
for OAuth1 orclient_secret
for OAuth2
- key -
-
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
- scope -
- 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
- 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 - optionally set specific
callback
for your provider in options.json instead of using the global one specified in server.json
MIT