Ad
PassportJs Google OAuth2 Callback Throws This Site Cant Be Reached Error
i'm trying to set up "Sign In with Google" in a personal project and when i call the google auth route i get a "this site cant be reached error" on callback.
My Routes:
app.get(
"/user/auth/google",
passport.authenticate("google", {
scope: [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email"
]
})
);
app.get(
"/user/auth/google/callback",
passport.authenticate("google", {
successRedirect: "/wsup",
failureRedirect: "/login"
}),
(req, res) => {
console.log("callback called");
}
);
My Google Strategy
passport.use(
new googleStrategy(
{
clientID: process.env.googleClientID,
clientSecret: process.env.googleClientSecret,
callbackURL: "https://localhost:3000/user/auth/google/callback",
proxy: true
},
(accessToken, refreshToken, profile, done) => {
console.log(profile.emails[0].value);
User.findOne({ googleId: profile.id }).then(user => {
if (user) {
console.log("existing");
done(null, user);
} else {
new User({ googleId: profile.id })
.save()
.then(newUser => done(null, newUser));
}
});
}
)
);
Response Text:
This site can’t be reached. localhost unexpectedly closed the connection.
i would like to add that i am testing this on localhost and i can see the code from google appended in the callback URl
Ad
Answer
i figured it out . the callback was trying to access https://localhost all i had to do was to change https to http in google Api console and it works like a charm
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad