Tag: passport facebook

在路由改变时重新加载不受ngRoutepipe理的控制器

我的Web应用程序login过程如下, 一个。 用户点击loginbutton,链接将它们带到http:// localhost:3030 / login / facebook 湾 NodeJS后端接收请求,并通过passport-facebook将浏览器导向Facebooklogin页面。 C。 Facebook然后用一些用户数据引导用户回到回叫。 (callback: http:// localhost:3030 / login / facebook / callback ) d。 通过用户数据,存在或将创build一个帐户,并创build一个属于该帐户的令牌(使用JWT) 即 该令牌将通过redirect到http:// localhost:3030 /#/ got_token / the_actual_jwt_string发送给用户 F。 AngularJS应用程序将采用ngRoute的路由,并将该令牌保存在localStorage中。 NodeJS中的令牌问题代码, server.get('/auth/facebook', passport.authenticate('facebook', {session: false})); server.get('/auth/facebook/callback', passport.authenticate('facebook', {session: false}), function(req, res) { var token = jwt.sign(/* issue a token */); // put […]

callpassUrl和passport-facebook中的函数之间的区别

我试图找出当使用passport-facebook和node / express时,Facebook身份validation是如何工作的。 我对callbackURL和下面的函数感到困惑。 有人可以向我解释什么是设置一个callbackURL(这是一个成功的login尝试结束?和函数(accessToken,…),似乎也是在login后调用之间的区别。 感谢帮助我理解这个模块! passport.use(new FacebookStrategy({ clientID: FACEBOOK_APP_ID, clientSecret: FACEBOOK_APP_SECRET, callbackURL: "http://localhost:3000/auth/facebook/callback" }, function(accessToken, refreshToken, profile, done) { User.findOrCreate({ facebookId: profile.id }, function (err, user) { return done(err, user); }); } ));

确定在哪个策略用户login

我的应用程序使用两种策略的护照:Facebook和本地。 是否有可能以某种方式(某些属性或状态variables)确定用户用来login应用程序的策略(即,根据Passport中的某些信息确定)? 在req对象中是否有一些属性或其他设置可以指示与login用户关联的提供者? 如果可能的话,我真的更喜欢从Passport那里得到这个,而不是设置我的owvariables来跟踪这个。

电子邮件字段在passportjs facebook策略中是可选的

我写了Facebook的login代码,一切正常,我得到用户的电子邮件地址。 但在Facebook上有另一个选项,让用户select我的应用程序将有权访问的数据。 如果用户点击它,他会看到名称和所有需要标记的内容,但是电子邮件是可选的,用户可以将其从要提供给应用程序的数据中移除。 在应用程序上,电子邮件是必需的。 那么如何在Facebook上标记电子邮件? 这是我在代码中使用的代码片段。 passport.use(new FacebookStrategy({ clientID: config.social.facebook.clientID, clientSecret: config.social.facebook.clientSecret, callbackURL: config.url+'auth/facebook/cb', enableProof: false, profileFields:['id', 'name', 'emails'], scope: "email" }, function(accessToken, refreshToken, profile, done) { // doing the rest of the thing } )); // … app.get('/auth/facebook', passport.authenticate('facebook', {scope: ['email']})); app.get('/auth/facebook/cb', passport.authenticate('facebook'), function(req, res, next) { res.redirect("/"); });

Phonegap在服务器端使用expressjs和passportjs进行身份validation

我使用nodejs和expressjs构build了一个使用passportjs进行身份validation的Web服务器。 我现在想用phonegap构build一个移动应用程序,当然也可以使用我现有的Web服务器来查询数据。 我需要在我的服务器上使用Facebook连接对我的用户进行身份validation,只有在创build会话时才能查询我的API。 我search了很多的解决scheme,什么都没find。 我看着InAppBrowser和ChildBrowser,但我不认为他们会做的伎俩,因为我需要保持会议活着,以查询api。 任何帮助,将不胜感激 谢谢

使用passport-facebook策略和passport-local无法将用户序列化到会话中

我在sails.js使用passport-local和passport-facebook策略进行身份validation。 使用电子邮件validation工作正常。 但是,当用户使用Facebook进行身份validation时,出现此错误消息[Error: Failed to serialize user into session] 。 然后我testing了serializeUser方法,事实certificate, user参数在facebook的情况下是空的。 虽然我也试着看看verifyHandler是否被调用,而不是被调用。 这是我的Facebook身份validation操作代码: facebook: function (req, res) { passport.authenticate('facebook', {failureRedirect: '/login', scope: ['email']}, function (err, user) { if ((err) || (!user)) { req.session.flash = { errMsg: 'Email or password mismatch.' } return res.redirect('/login'); } req.logIn(user, function (err) { if (err) { console.log(err); res.view('500'); return; […]

Express JS res.redirect是未定义的

我按照这个教程如何使用MEAN堆栈中的passport-facebook,当我尝试使用res.redirect('/signup')我得到了这个错误我总是得到这个错误: ReferenceError: res is not defined 好像我没有通过res作为我的函数参数。 我尝试在第二个/最后一个参数中添加它。 但没有任何工作。 我错过了什么? 这是我的代码: exports.saveOAuthUserProfile = function(req, profile, done){ User.findOne({ provider: profile.provider, providerId: profile.providerId, }, function(err, user) { if (err) { return done(err); } else { if (!user) { // console.log(profile.email.value); var possibleUsername = profile.username || ((profile.email) ? profile.email.value.split('@')[0] : ''); User.findUniqueUsername(possibleUsername, null, function(availableUsername){ profile.username = availableUsername; user […]

拒绝访问网页使用护照中间件的Facebook

我正在写一个“ todolist ”web应用程序。 在我的服务器端代码(node.js)中,我使用护照中间件来允许用户使用Facebooklogin。 我的一些服务器端代码: var passport = require('passport') , FacebookStrategy = require('passport-facebook').Strategy; passport.use(new FacebookStrategy({ clientID: '5669xxxxxxxxxx', clientSecret: '555022xxxxxxxxxxxxxxxxx', callbackURL: 'http://www.localhost:3000/Todolistpage.html' }, function(accessToken, refreshToken, profile, done) { User.findOrCreate(…, function(err, user) { if (err) { return done(err); } done(null, user); }); } )); //Authentication app.get('/auth/facebook', passport.authenticate('facebook')); app.get('/auth/facebook/Todolistpage.html', passport.authenticate('facebook', { successRedirect: '/Todolistpage.html', failureRedirect: '/' })); 1)我不知道什么“ User.findOrCreate(.. […]

无法testing第三方授权:Node / Express / Supertest / Facebook

我正在编写一个非常早期的Node / Express应用程序的testing。 我已经决定只为大多数用户使用FBlogin,所以我的许多控制器都依赖于来自FB的身份validation状态。 但我不清楚如何testing这个,或者如何保持会话与login用户的方式,我正在使用的护照,将理解。 var expect = require("chai").expect; var mongoose = require('mongoose'); var User = require('../models/users'); var nock = require('nock'); var parser = require('cookie-parser') var session = require('supertest-session'); var agent = require('superagent'); var _ = require('lodash'); var app = require('../app'); var testSession = null; var fbRedirectURL; beforeEach(function () { testSession = session(app); }); it('should […]

节点Facebook Passport无论发送范围如何,都只返回某些字段

我目前正在尝试使用Koa-Passport和Koajs 2来实现Facebook的OAUTH 一切工作正常,我可以login,什么不是,但不pipe我发送的范围,我只得到: { passport: { user: { id: '1015401', username: undefined, displayName: 'John Doe', name: [Object], gender: undefined, profileUrl: undefined, provider: 'facebook', _raw: '{"name":"John Doe","id":"1015401"}', _json: [Object] } } } 我试过添加 scope: ['email', 'public_profile']这似乎在Facebook上工作结束,因为我可以看到我的应用程序正在请求的信息,所有的东西在那里。 但是,当我点击确定,我重新导向回到我的应用程序,再次我失去了像一个profile_pic字段和email字段的东西。 任何有关如何获得这些领域的信息将非常感谢。 我会在github页面上打开一个问题,但是有一些问题可以追溯到2013年,它似乎没有被保留太多。