Last active
December 19, 2017 18:24
-
-
Save rbhatia46/bfc98c463664582f9044c81a66d52073 to your computer and use it in GitHub Desktop.
Boilerplate to authenticate using Google using Passport.js and Express Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const passport = require('passport'); | |
| const GoogleStrategy = require('passport-google-oauth20').Strategy; | |
| const keys = require('./config/keys'); | |
| const app = express(); | |
| passport.use(new GoogleStrategy({ | |
| clientID : keys.googleClientID, | |
| clientSecret : keys.googleClientSecret, | |
| callbackURL : '/auth/google/callback' | |
| }, (accessToken, refreshToken, profile, done) => { | |
| console.log('accessToken',accessToken); | |
| console.log('refreshToken',refreshToken); | |
| console.log('profile',profile); | |
| }) | |
| ); | |
| app.get('/auth/google', passport.authenticate('google',{ | |
| scope : ['profile','email'] | |
| })); | |
| app.get('/auth/google/callback',passport.authenticate('google')); | |
| const PORT = process.env.PORT || 5000; | |
| app.listen(PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment