初めてパスポートを設定しようとしていて、Google サインイン オプションを 1 つだけ使用しています。Google apis に登録したので、すべての設定が完了しました。関連するコードは以下のとおりですが、アプリが'/auth/google/'
呼び出しを行うと、応答やエラー メッセージが表示されずに失敗します。構成をさまざまな方法で切り替えましたが、役に立ちませんでした。passport.authenticate('google')
また、匿名関数を console.log に置き換えて、Web サービスが正しく動作していることを再確認しました。だから私はそれがに近づいていることを知っていpassport.authenticate('google')
ます。
// 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-clickに関連付けられています。
$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);
});
};
それらのログは何も返さない