Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const passport = require("passport");
- const GoogleStrategy = require('passport-google-oauth20').Strategy;
- let googleOptions = {
- clientID: ENV.GOOGLE_CLIENT_ID,
- clientSecret: ENV.GOOGLE_CLIENT_SECRET,
- callbackURL: "/user/auth/google/callback"
- };
- passport.use(new GoogleStrategy(googleOptions,
- function(token, refreshToken, profile, done) {
- // make the code asynchronous
- console.log("googleStrategy");
- process.nextTick(async () => {
- console.log(profile);
- });
- }
- ));
- app.get('/auth/*/google', passport.authenticate('google', { scope: ['profile'] }));
- app.get('/auth/google/callback', passport.authenticate('google', {
- failureRedirect: '/auth' }),
- function(req, res) {
- // Successful authentication, redirect home.
- res.redirect('/');
- });
Add Comment
Please, Sign In to add comment