Giter Site home page Giter Site logo

mjhea0 / passport-examples Goto Github PK

View Code? Open in Web Editor NEW
93.0 8.0 60.0 671 KB

social auth for node

Home Page: http://mherman.org/blog/2013/11/10/social-authentication-with-passport-dot-js/

License: MIT License

JavaScript 72.25% Makefile 0.37% HTML 15.24% CSS 12.14%

passport-examples's Introduction

Social Authentication with Passport.js

Updated on November 27th, 2015 - Refactored and added Instagram Authentication

Final project:

fb

Quick Start

  1. Clone
  2. npm install
  3. Add oauth.js file to the root and add the social IDs and keys:
var ids = {
  facebook: {
    clientID: 'get_your_own',
    clientSecret: 'get_your_own',
    callbackURL: 'http://127.0.0.1:1337/auth/facebook/callback'
  },
  twitter: {
    consumerKey: 'get_your_own',
    consumerSecret: 'get_your_own',
    callbackURL: 'http://127.0.0.1:1337/auth/twitter/callback'
  },
  github: {
    clientID: 'get_your_own',
    clientSecret: 'get_your_own',
    callbackURL: 'http://127.0.0.1:1337/auth/github/callback'
  },
  google: {
    clientID: 'get_your_own',
    clientSecret: 'get_your_own',
    callbackURL: 'http://127.0.0.1:1337/auth/google/callback'
  },
  instagram: {
    clientID: 'get_your_own',
    clientSecret: 'get_your_own',
    callbackURL: 'http://127.0.0.1:1337/auth/instagram/callback'
  }
};

module.exports = ids;
  1. Run node app.js

passport-examples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

passport-examples's Issues

Double Quotes

Your github and twitter objects in oauth.js has double quotes around the callbackURL instead of single quotes.

TypeError: OAuth2Strategy requires a clientID option

It seems the Google Strategy requires to have a clientID option.

/Users/someone/development/nurtureNetworks/passport-examples/node_modules/passport-google-oauth2/node_modules/passport-oauth2/lib/strategy.js:83
  if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clie
                                 ^
TypeError: OAuth2Strategy requires a clientID option
    at Strategy.OAuth2Strategy (/Users/someone/development/nurtureNetworks/passport-examples/node_modules/passport-google-oauth2/node_modules/passport-oauth2/lib/strategy.js:83:34)
    at new Strategy (/Users/someone/development/nurtureNetworks/passport-examples/node_modules/passport-google-oauth2/lib/oauth2.js:48:18)
    at Object.<anonymous> (/Users/someone/development/nurtureNetworks/passport-examples/authentication.js:103:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/someone/development/nurtureNetworks/passport-examples/app.js:10:14)

missing file

$ node app

module.js:340
    throw err;
          ^
Error: Cannot find module './oauth.js'

Callback error

Hi, I'm new in node and trying to sget a simple fb authentication work
here is my code

unfortunately the callback ... function(accessToken, refreshToken, profile, done) is not fired
What did go wrong in here?

thanks for your help

/**
 * Module dependencies.
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var facebook = require('./routes/facebook');
var http = require('http');
var path = require('path');
var passport = require('passport')
var FacebookStrategy = require('passport-facebook').Strategy;
var app = express();
var config = require("./oauth");
// all environments
app.set('port', process.env.PORT || 8080);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

passport.use(new FacebookStrategy({
    clientID: config.facebook.clientID,
    clientSecret: config.facebook.clientSecret,
    callbackURL: config.facebook.callbackURL
  },
  function(accessToken, refreshToken, profile, done) {
    console.log("accessToken" + accessToken);
    console.log(refreshToken);
    console.log(profile);
    console.log(done);
  }
));
// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);
app.get('/auth/facebook', 
     passport.authenticate('facebook', { scope: ['read_stream', 'publish_actions'] })
);
app.get('/auth/facebook/callback', facebook.callback);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.