slogin
v0.0.5
Published
Log in to your social network
Downloads
2
Readme
##Welcome to slogin
slogin module allows to get users information from the social network like Facebook, Github, Gmail and etc. Currently it only support Facebook and Github.
##Installation
npm install slogin
##Quick Start
slogin module require app(client) id, secret (consumer) key, redirect url and network proxy (optional). Regester your application on facebook( Click here ), on github( Click here ) in order to get client id and secret key.
// Facebook authentication
var provider = "facebook",
options = {
clientID: "Add facebook clientID",
secretKey: "Add facebook secret key",
redirectURL: "Add redirect url"
},
proxy="";
//Initialization facebook objects... .. .
var fb = require('slogin').oauth(provider, options, proxy);
//Initialization github objects... .. .
var git = require('slogin').oauth(provider, options, proxy);
// Get facebook login url and redirect it for user authentication
fb.getLogin(function(err, url){
if(!err){
// Please add your code that make a request using facebook login url
}
});
// Get github login url and redirect it for user authentication
git.getLogin(function(err, url){
if(!err){
// Please add your code that make a request using facebook login url
}
});
Above code will ask user to enter his credentials and if user enter correct credentials then fb callback to redirect url with unique code as a query parameter. This unique code is require to get user info.
Once you get user code, follow below code to get user details
//get fecebook user details
fb.getUserDetails(code, function(err, userDetails){
console.dir(userDetails);
});
//get github user details
fb.getUserDetails(code, function(err, userDetails){
console.dir(userDetails);
});