7
我正在尝试第一次设置护照,并且只使用一个Google登录选项。我在谷歌apis注册,所以我有所有的设置。相关的代码如下,但是当我的应用程序调用'/auth/google/'
时,它只是失败,没有响应或错误消息。我已经调整了一些配置的方式无济于事。我还用一个console.log替换了带有匿名函数的passport.authenticate('google')
,以仔细检查我的Web服务是否正常运行。所以我知道它正在进入passport.authenticate('google')
。Passport.js身份验证不起作用
// serialize session
passport.serializeUser(function (user, done) {
done(null, user.id);
});
passport.deserializeUser(function (obj, done) {
done(null, obj);
});
// use google strategy
passport.use(new googleStrategy({
clientID: config.google.clientID,
clientSecret: config.google.clientSecret,
callbackURL: config.google.callbackURL,
scope: 'https://www.google.com/m8/feeds https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'
},
function(accessToken, refreshToken, profile, done) {
console.log(profile);
}
));
app.use(passport.initialize());
app.use(passport.session());
app.get('/auth/google', passport.authenticate('google'));
app.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: '/', scope: 'https://www.google.com/m8/feeds' }), signin);
编辑:一个按钮 这里是我的HTTP请求,我使用的角度和这个功能是绑在NG-点击。
$scope.signIn = function() {
$http({method: 'GET', url: '/auth/google'}).
success(function (data, status, headers, config) {
console.log('success');
}).
error(function (data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
});
};
这些日志返回任何
你真的有没有错误信息?超时也许?它如何失败? – maxdec
我一直无法赶上或得到任何回报。它似乎失败,没有任何类型的返回。也许有那个电话配置错误。我会添加我的ajax代码以防万一。 –