-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle.js
More file actions
32 lines (27 loc) · 976 Bytes
/
Copy pathgoogle.js
File metadata and controls
32 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var passport = require('passport');
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var User = require('./User');
passport.serializeUser(function (user, done) {
done(null, user);
})
passport.deserializeUser(function (obj, done) {
done(null, obj);
})
passport.use(new GoogleStrategy({
clientID: "288577850664-i4tta03f23tim3rvtclh3djv7lqvam0i.apps.googleusercontent.com",
clientSecret: "WppgzIWhvgKzYzM-x1gC4uEw",
callbackURL: "http://localhost:3000/login/google/callback"
},
function (accessToken, refreshToken, profile, done) {
console.log('Objeto Profile: ' + JSON.stringify(profile));
User.findOrCreate({ userid: profile.id }, {
name: profile.displayName,
userid: profile.id,
email: profile.emails[0].value,
photo: profile._json.image.url
}, function (err, user) {
return done(err, user);
});
}
));
module.exports = passport;