Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cordova-plugin-googleplus + passport-google-id-token #29

Open
publicbar opened this issue Nov 28, 2018 · 1 comment
Open

cordova-plugin-googleplus + passport-google-id-token #29

publicbar opened this issue Nov 28, 2018 · 1 comment

Comments

@publicbar
Copy link

Hi,
I've got client (cordova plugin) logging in ok and getting the idtoken on android device.
I then post this to my server (localhost). (req.body.id_token) I get no errors:
I tried another plugin that verifies the idtoken and that works.

Code:

passport.use(new GoogleTokenStrategy({
clientID: '123433.apps.googleusercontent.com',
getGoogleCerts: null
},
function(parsedToken, googleId, done) {
console.log(parsedToken); <--------- Never gets here
User.findOrCreate({ googleId: googleId }, function (err, user) {
return done(err, user);
});
}
));

router.post('/auth/google', function(req, res, next){
verifier.verify(req.body.id_token, '1234.apps.googleusercontent.com', function (err, tokenInfo) {
if (!err) {
// use tokenInfo in here.
console.log(tokenInfo); <--gets here OK
}
});
passport.authenticate('google-id-token', function(req, res){
res.send(req.user? 200 : 401); <-- never gets here.
});
});

I stepped into passport/lib/authenticate.js line 81
and code never enters the function below.
return function authenticate(req, res, next) {

I believe I'm overlooking something obvious but its taking me a very long time to find out what.
Any clues appreciated!
Thanks

@publicbar
Copy link
Author

No sooner I posted this I found I needed to do this:

passport.authenticate('google-id-token', function(req, res){
res.send(req.user? 200 : 401);

})(req,res,next); <-- HERE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant