Guest User

Untitled

a guest
Jan 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. const passport = require("passport");
  2. const GoogleStrategy = require('passport-google-oauth20').Strategy;
  3.  
  4. let googleOptions = {
  5. clientID: ENV.GOOGLE_CLIENT_ID,
  6. clientSecret: ENV.GOOGLE_CLIENT_SECRET,
  7. callbackURL: "/user/auth/google/callback"
  8. };
  9. passport.use(new GoogleStrategy(googleOptions,
  10. function(token, refreshToken, profile, done) {
  11. // make the code asynchronous
  12. console.log("googleStrategy");
  13. process.nextTick(async () => {
  14. console.log(profile);
  15. });
  16. }
  17. ));
  18.  
  19. app.get('/auth/*/google', passport.authenticate('google', { scope: ['profile'] }));
  20.  
  21. app.get('/auth/google/callback', passport.authenticate('google', {
  22. failureRedirect: '/auth' }),
  23. function(req, res) {
  24. // Successful authentication, redirect home.
  25. res.redirect('/');
  26. });
Add Comment
Please, Sign In to add comment