"passport google oauth20" Code Answer's
You're definitely familiar with the best coding language Go that developers use to develop their projects and they get all their queries like "passport google oauth20" answered properly. Developers are finding an appropriate answer about passport google oauth20 related to the Go coding language. By visiting this online portal developers get answers concerning Go codes question like passport google oauth20. Enter your desired code related query in the search bar and get every piece of information about Go code related question on passport google oauth20.
passport google oauth20
//To install
npm install passport-google-oauth20
//To Acquire it
var GoogleStrategy = require('passport-google-oauth20').Strategy;
//To use findOrCreate install the package <findorcreate-mongoose>
passport.use(new GoogleStrategy({
clientID: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
callbackURL: "http://www.example.com/auth/google/callback"
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ googleId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
//GET Route
app.get('/auth/google',
passport.authenticate('google', { scope: ['profile'] })
);
//Callback GET Route from Google
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
All those coders who are working on the Go based application and are stuck on passport google oauth20 can get a collection of related answers to their query. Programmers need to enter their query on passport google oauth20 related to Go code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about passport google oauth20 for the programmers working on Go code while coding their module. Coders are also allowed to rectify already present answers of passport google oauth20 while working on the Go language code. Developers can add up suggestions if they deem fit any other answer relating to "passport google oauth20". Visit this developer's friendly online web community, CodeProZone, and get your queries like passport google oauth20 resolved professionally and stay updated to the latest Go updates.