여기에서 뭔가를 놓쳐 야합니다. 나는 passportjs의 Facebook 전략을 사용하여 사용자를 인증합니다.passportjs facebook pass 콜백 요청
//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 생성자 나에게 도움이되지 않습니다 확인 콜백 (내가 처음 request.body을 원하는)
다음 일은 다시 최신 요청을 보냅니다 'passReqToCallback'에 사용할 수있는 옵션이 있습니다
그 , 그럴듯한 경로를 보았다 https://github.com/jaredhanson/passport-oauth/blob/master/lib/passport-oauth/strategies/oauth2.js#L169
에서와 같이 '상태'옵션을 사용했다 그러나이 값은 https://github.com/jaredhanson/passport-oauth/blob/master/lib/passport-oauth/strategies/oauth2.js#L124
나의 현재 옵션은 OAuth2Strategy 내부에 별도의 변수를 추가하는 것입니다 getOAuthAccessToken 콜백에 사용할 수 없습니다 .prototype.authenticate() 함수는 첫 번째 함수에서 설정되고 콜백 함수로 변경되지 않은 상태로 전달되지만이 방법이 있다고 생각하지 않습니다. 당신이 무엇을 설명에서
U r life savior :)) –