node.js - facebook login error - using MEAN -


i new mean. i've been trying create 'facebook' login new mean application. making use of strategy from: "passport-facebook".

the code user.js file, i've created new schema facebook users follows:

var mongoose = require('mongoose');  var fbuserschema = mongoose.schema({     id: string,     token: string,     email: string,     name: string });  var fbuser = mongoose.model('fbuser', fbuserschema); 

my passport.js file has this:

var fbuser = mongoose.model('fbuser'),     facebookstrategy = require('passport-facebook').strategy;  module.exports = function(){ passport.serializeuser(function (user, done) {         if (user) {             done(null, user.id);         }     });      passport.deserializeuser(function (id, done) {         user.findone({_id: id }).exec(function (err, user) {             if (user) {                 return done(null, user);             } else {                 return done(null, false);             }         });     });      passport.use(new facebookstrategy({             'clientid' : 'xxxxxxxxxxxxxxx',             'clientsecret' : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',             'callbackurl' : 'http://localhost:3030/auth/facebook/callback'         },         function(accesstoken, refreshtoken, profile, done) {             process.nexttick(function(){                 fbuser.findone({'id':profile.id}, function(err, user){                     if(err){                         return done(err);                     }                     if(user){                         return done(null, user);                     }                     else{                         var newuser = new fbuser();                         newuser.id = profile.id;                         newuser.token = accesstoken;                         newuser.name = profile.name.givenname + ' ' + profile.name.familyname;                         newuser.email = profiel.emails[0].value;                          newuser.save(function(err){                             if(err){                                 throw err;                             }                             return done(null, newuser);                         });                     }                 });             });         })     ) } 

and routes.js has:

var auth = require('./auth'),     users = require('../controllers/users'),     mongoose = require('mongoose'),     user = mongoose.model('user'),     fbuser = mongoose.model('fbuser'),     passport = require('passport');  module.exports= function(app) {      app.get('/api/users', auth.requiresrole('admin'), users.getusers);     app.post('/api/users', users.createuser);     app.put('/api/users', users.updateuser);      app.get('/partials/*', function (req, res) {         res.render('../../public/app/' + req.params[0]);     });      app.post('/login', auth.authenticate);      app.get('/auth/facebook', passport.authenticate('facebook'));      app.get('/auth/facebook/callback',         passport.authenticate('facebook', { successredirect: '/',             failureredirect: '/login' }));      app.post('/logout', function(req,res){         req.logout();         res.end();     });      app.get('*', function (req, res) {         res.render('index', {             bootstrappeduser: req.user         });     });  } 

i have provided the:

a(href="/auth/facebook") facebook 

in login.jade file.

when click on link though getting error saying:

the parameter redirect_uri required 

can please me on issue.

my facebook url follows:

https://www.facebook.com/v2.2/dialog/oauth?response_type=code&redirect_uri=&client_id=xxxxxxxxxxxxxxxx 

i missing "redirect_uri=" value in this. how that?

mean had facebook support; go facebook.js under config/strategies/ change facebook id , app secret according 1 filled in facebook website. thats it


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -