11
我必須使用護照谷歌-的OAuth以下節點的代碼...護照谷歌,OAuth的回調不工作
app.get('/auth/google', passport.authenticate('google', { scope : ['profile', 'email'] }));
app.get('/auth/google/callback', function(req,res) {
console.log("callback");
passport.authenticate('google', {
successRedirect : '/signin',
failureRedirect : '/signin'
});
});
和...
passport.serializeUser(function(user, done) {
console.log("ser");
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
console.log("des");
User.findById(id, function(err, user) {
done(err, user);
});
});
passport.use(new GoogleStrategy({
clientID : 'id',
clientSecret : 'key',
callbackURL : 'http://host/auth/google/callback',
},
function(token, rtoken, profile, done) {
console.log("proc");
console.log(profile);
done(null, profile);
}));
的問題是,回調被叫,但沒有其他事情發生。處理功能從未命中。回調結束超時。任何想法,我出錯了?
是行'console.log(「callback」);'執行了嗎? – xShirase 2014-10-06 18:16:45
你還有什麼/登錄路線的樣子?也應該回調是一個get或post。我認爲這通常是一個職位。 – 2014-10-06 22:59:17
也許你的問題出現在GoogleStrategy中。試試這個:var GoogleStrategy = require('passport-google-oauth')。OAuth2Strategy; – Dyrk 2015-05-07 11:04:31