ユーザーの Facebook プロフィール情報を受け取ったら、(Cookie を設定するために) 応答にアクセスするにはどうすればよいですか?
// the function that contains `profile` does not contain request (cookies)
passport.use(new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
callbackURL: authHost + '/auth/facebook/callback'
}, function(accessToken, refreshToken, profile, done) {
var cookies = cookie.parse(res.headers.cookie); // <-- how can I access cookies?
}));
// however, this function does have access to cookies
app.get('/auth/facebook/callback', function(req,res,done){
passport.authenticate('facebook', {
failureRedirect: '/login.php?failureRedirect=true',
successRedirect: 'http://localhost/?loggedIn=true'
});
var cookies = cookie.parse(req.headers.cookie)); // <-- √ request is available
});