我必须在这里俯瞰的东西。我正在使用passportjs的Facebook策略来验证用户身份。这是与2个请求/ [路由执行]完成:passportjs脸谱通过要求回电
//one to initiate the the auth:
init: function (req, res, next) {
passport.authenticate('facebook', {
callbackURL: URL + '/facebook/callback',
state: req.body //attempting to put some state
})(req, res, next)
}
//one callback
callback: function (req, res, next) {
passport.authenticate('facebook', {
callbackURL: URL + '/facebook/callback'
},
function (err, profile, accessToken, refreshToken) {
if (err) return next(err)
res.send(passedReqBody)
})(req, res, next)
}
//the verify callback doesn't do much.
//Application logic is done in route callback handlers
passport.use(new FacebookStrategy({
clientID: config.facebook.id,
clientSecret: config.facebook.secret
},
//When setting passReqToCallback to true, it is set as the first argument
//to the verify callback. As in:
//function (req, accessToken, refreshToken, params, profile, done) {
//But this is the 'callback' request object. I want the 'init' request object.
function (accessToken, refreshToken, params, profile, done) {
//params.state is undefined
return done(null, profile, accessToken, refreshToken);
}));
我的问题是,我想第一个函数的POST请求体在回调路由处理被曝光。
有到OAuth2Strategy构造“passReqToCallback”,它发送的最新要求回验证回调,这是没有用的,我(我想第一request.body)
接下来的事情提供一个选项,看着一个合理的路径,是使用了“状态”选项,如在https://github.com/jaredhanson/passport-oauth/blob/master/lib/passport-oauth/strategies/oauth2.js#L169
但这些值不可对getOAuthAccessToken回调https://github.com/jaredhanson/passport-oauth/blob/master/lib/passport-oauth/strategies/oauth2.js#L124
我现在的选择是添加OAuth2Strategy内一个额外的变量.prototype.authenticate ()函数,该函数在第一个函数中被设置,并且被传回回调函数,但我无法想象这是要走的路。
你的生活救星:)) –