npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sociallogin

v0.0.15

Published

Login usng several social providers

Downloads

26

Readme

Social Login

Social login is a library that integrates several passportJS auth provider libraries in a unified way. You just need to provide your specific credentials for each provider and your website url.

List of available providers and urls to create authentication keys

  • facebook https://developers.facebook.com/
  • twitter https://apps.twitter.com/
  • github https://github.com/settings/applications
  • google https://console.developers.google.com/project
  • linkedin https://www.linkedin.com/secure/developer
  • amazon http://login.amazon.com/manageApps
  • bitbucket https://bitbucket.org/account/user/USERNAME/api
  • dropbox https://www.dropbox.com/developers/apps
  • evernote https://dev.evernote.com/key.php
  • fitbit https://dev.fitbit.com/apps
  • flickr https://www.flickr.com/services/apps/
  • foursquare https://foursquare.com/developers/apps
  • instagram http://instagram.com/developer/clients/manage/
  • meetup https://secure.meetup.com/meetup_api/oauth_consumers/
  • spotify https://developer.spotify.com/my-applications/#!/applications
  • trello https://trello.com/1/appKey/generate
  • tumblr https://www.tumblr.com/oauth/apps
  • vimeo https://developer.vimeo.com/apps
  • windowslive https://account.live.com/developers/applications/index
  • wordpress https://developer.wordpress.com/apps/
  • yahoo https://developer.apps.yahoo.com/projects

install

npm install sociallogin

setup


// Initialise package
var sociallogin = require('sociallogin');

// Add Strategies function call
sociallogin.addPassportStategies(passportModule, config, userAuthenticationCallback, siteUrl);
* passportModule - an instance of the passportJS module
* config - a json object that holds the configured providers and their credentials
The following will only activate the windowslive, wordpress and yahoo providers for your application
windowslive: {
    clientID: 'XXXXXXXXXXXXXXXXXXXXX',
    clientSecret: 'XXXXXXXXXXXXXXXXXXXXX'
},
wordpress: {
    clientID: 'XXXXXXXXXXXXXXXXXXXXX',
    clientSecret: 'XXXXXXXXXXXXXXXXXXXXX'
},
yahoo: {
    clientID: 'XXXXXXXXXXXXXXXXXXXXX--',
    clientSecret: 'XXXXXXXXXXXXXXXXXXXXX'
}
* userAuthenticationCallback(providerId,providerName,displayName,emailAddress,username,passportDone) - callback function that gives user information to register or login a user . Implement your own based on the user needed for your application.
// providerId - the unique identifier based on the oauth provider
// providerName - the provider name based on the above list e.g google
// displayName - display name from the provider (might be undefined)
// emailAddress - email address from the provider (might be undefined)
// username - username from the provider (might be undefined)
// passportDone(err,user) - passportJS function that you need to call when the user is created or when an error occured
e.g
function addUser(providerId,providerName,displayName,emailAddress,username,passportDone){
      User.findOne({
          'providerId': providerId,
          'providerName': providerName
      }, function(err, user) {
          if (err) {
              return passportDone(err);
          }
          if (!user) {
              user = new User({
                  name: displayName,
                  username: username || emailAddress.split('@')[0],
                  providerName: providerName,
                  providerId: providerId,
                  email: emailAddress,
                  roles: ['authenticated']
              });
              user.save(function(err) {
                  if (err) console.log(err);
                  return passportDone(err, user);
              });
          } else {
              return passportDone(err, user);
          }
      });
  }
* siteUrl - the website url and protocol (https is recomended) that uses this plugin e.g https://sociallogin.heroku.com

// Add authentication urls
sociallogin.addAuthenticationUrls(passportModule, expressModule,signInController, authenticationController, failureRedirectUrl, config);
* passportModule - an instance of the passportJS module
* expressModule - an instance of the express app
* signInController(req,res) - check if user is authenticated and redirect
e.g
function(req, res) {
  if (req.isAuthenticated()) {
    return res.redirect('/');
  }
  res.redirect('#!/login');
};
* authenticationController(req,res) - authenticated user callback
function(req, res) {
  res.redirect('/');
};
* failureRedirectUrl - url to redirect to if authentication fails
e.g '#!/login'
* config - a json object that holds the configured providers and their credentials. Same as above

// Add urls for provider specific authentication to your views. All the configured providers will be accessible with your applicationUrl/oauth/providerName
e.g
<a href="/auth/yahoo" class="button">
    <span>Log In With Yahoo</span>
</a>