passport-google-id-token icon indicating copy to clipboard operation
passport-google-id-token copied to clipboard

Does it still work?

Open bouchtaoui-dev opened this issue 4 years ago • 4 comments

Hello friends,

Somehow the passport-google-id-token package doesn't work for me. I'm a bit new to node.js but I am an experienced programmer on another field.

Why is (parsedToken, googleId, done) => {} not called? I hope you can help me.

passport-setup.js

const passport = require('passport');
const GoogleTokenStrategy = require('passport-google-id-token');
...
...

passport.use(new GoogleTokenStrategy({
    clientID: "3530000000-xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"
  }, (parsedToken, googleId, done) => {
      console.log('Google callback token!')   // <-- not called here
    done({}, {});
  }
));

login.js

router.post('/google/token', passport.authenticate('google-id-token'), (req, res) => {
    res.send({
        tokenid: 'GOOGLE TOKEN ID'
    });
});

Any idea?

bouchtaoui-dev avatar Nov 11 '20 18:11 bouchtaoui-dev

@Nordin-010 Yes I managed to get this library to work. Actually in your login.js you should actually send the id token from the client and then this library just verifies the token for you. I'm not sure if that's what you're trying to do

magp3 avatar Dec 21 '20 12:12 magp3

Thnx @magp3 . I finally used the Google's own variation: Google Auth2.0

and that works for me perfectly. But I'm not using passport lib. Maybe next time I manage to get it work :)

bouchtaoui-dev avatar Dec 23 '20 12:12 bouchtaoui-dev

@magp3 Can you desbribe better how perfome a request?A always get 404. I tried pass a json in body with "idToken" and the idToken.

Math-O5 avatar Jul 27 '22 02:07 Math-O5

Its id_token see here: https://github.com/jmreyes/passport-google-id-token/blob/657fdc7e60e19e5610d6bc76f7b447cb3a92100a/lib/passport-google-id-token/strategy.js#L109

But if you're getting a 404 the problem might be elsewhere since passport should be giving back 401. And yes this is still working, I have it in a live project so I think this issue should be closed.

ferdinandyb avatar Jul 27 '22 18:07 ferdinandyb