Social-login is a utility built on top of PassportJS that makes it a lot faster to setup various social logins on your site, without having to deal with PassportJS' complicated and non-standardized API.
Social-login also pre-parse the data to return only the part you care about. It will also return the name of the unique property in the data ('id', 'ID', 'name', ...), so that you can identify the user's account easily.
You can literally setup a social login for 13 social sites in less than 10 minutes, without headache.
var express = require('express');
var app = express();
var socialLoginClass = require("social-login");
var socialLogin = new socialLoginClass({
app: app,
url: 'http://127.0.0.1:5000',
onAuth: function(req, type, uniqueProperty, accessToken, refreshToken, profile, done) {
findOrCreate({
profile: profile,
property: uniqueProperty,
type: type
}, function(user) {
done(null, user);
});
}
});
socialLogin.use({
facebook: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET",
authParameters: {
scope: 'read_stream,manage_pages'
}
},
url: {
auth: "/auth/facebook",
callback: "/auth/facebook/callback",
success: '/',
fail: '/auth/facebook/fail'
}
},
twitter: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/twitter",
callback: "/auth/twitter/callback",
success: '/',
fail: '/auth/twitter/fail'
}
},
instagram: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/instagram",
callback: "/auth/instagram/callback",
success: '/',
fail: '/auth/instagram/fail'
}
},
github: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/github",
callback: "/auth/github/callback",
success: '/',
fail: '/auth/github/fail'
}
},
linkedin: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET",
authParameters: {
scope: ['r_basicprofile', 'r_emailaddress', 'r_fullprofile', 'r_contactinfo', 'r_network', 'rw_nus']
}
},
url: {
auth: "/auth/linkedin",
callback: "/auth/linkedin/callback",
success: '/',
fail: '/auth/linkedin/fail'
}
},
google: {
settings: {},
url: {
auth: "/auth/google",
callback: "/auth/google/callback",
success: '/',
fail: '/auth/google/fail'
}
},
amazon: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET",
authParameters: {
scope: ['profile', 'postal_code']
}
},
url: {
auth: "/auth/amazon",
callback: "/auth/amazon/callback",
success: '/',
fail: '/auth/amazon/fail'
}
},
dropbox: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/dropbox",
callback: "/auth/dropbox/callback",
success: '/',
fail: '/auth/dropbox/fail'
}
},
foursquare: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/foursquare",
callback: "/auth/foursquare/callback",
success: '/',
fail: '/auth/foursquare/fail'
}
},
imgur: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/imgur",
callback: "/auth/imgur/callback",
success: '/',
fail: '/auth/imgur/fail'
}
},
meetup: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/meetup",
callback: "/auth/meetup/callback",
success: '/',
fail: '/auth/meetup/fail'
}
},
wordpress: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/wordpress",
callback: "/auth/wordpress/callback",
success: '/',
fail: '/auth/wordpress/fail'
}
},
tumblr: {
settings: {
clientID: "YOUR_API_KEY",
clientSecret: "YOUR_API_SECRET"
},
url: {
auth: "/auth/tumblr",
callback: "/auth/tumblr/callback",
success: '/',
fail: '/auth/tumblr/fail'
}
}
});
Do you need to receive the raw data returned by the Oauth login rather than the filtered one?