jmreyes / passport-google-id-token

Google ID token authentication strategy for Passport and Node.js.
MIT License
44 stars 22 forks source link

Does it still work? #33

Open bouchtaoui-dev opened 3 years ago

bouchtaoui-dev commented 3 years ago

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?

magp3 commented 3 years ago

@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

bouchtaoui-dev commented 3 years ago

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 :)

Math-O5 commented 2 years ago

@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.

ferdinandyb commented 2 years ago

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.