1.0.1 • Published 5 years ago

gpluslogin v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Gooogle Plus Login

This will allow you to add google Plus login to your application

Things to do

Create env file 
add data to env file

add to express layer

// GLOBAL IMPORT START
import express from 'express';
import passport from 'passport';
import cookieParser from 'cookie-parser';
import cookieSession from 'cookie-session';
import dotenv from 'dotenv';
// GLOBAL IMPORT END

// LOCAL IMPORT START
import auth from "./passport";
import { CheckLogin,Logout,LoginCallback } from "./requests/request";
// LOCAL IMPORT END

const app = express();
const env = process.env;
dotenv.config(); // add .env file config
auth(passport);
app.use(passport.initialize());
app.use(cookieSession({
    name: 'session',
    keys: [env.COOKIES_SECRET_CODE],
    maxAge: 24 * 60 * 60 * 1000
}));
app.use(cookieParser());
app.get('/', CheckLogin );
app.get('/logout', Logout);
app.get('/login', passport.authenticate('google', {
    scope: ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email']
}));
app.get('/callback',passport.authenticate('google', {failureRedirect: '/'}),LoginCallback);
app.listen(4000, () => {
    console.log('Server is running on port 3000');
});