I use passport.js to authenticate users. I would like to be able to pass in the username collected from the user that will reach the end of the authentication process so that I can save the username when creating the user (if it does not already exist). I tried this:
app.get("/auth/google", function(request, response) { console.log(request.query.username); passport.authenticate("google", { scope: [ "https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email" ] })(request, response); }); app.get("/auth/google/callback", function(request, response) { console.log(request.query.username); passport.authenticate("google", { successRedirect: "/", failureRedirect: "htm/error" })(request, response); });
Calling / auth / google displays the username, but the callback prints undefined. Even if I could get the username for the callback, I'm still not sure how to get it in the google strategy. Should I then create my own strategy to get this to work?
Mike pateras
source share