-
Notifications
You must be signed in to change notification settings - Fork 0
/
GooglePassport.ts
48 lines (41 loc) · 1.7 KB
/
GooglePassport.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import googleAppAuth from './googleOauth';
let passport = require('passport');
//let GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
let GoogleStrategy = require('passport-google-oauth20-with-people-api').Strategy;
// Creates a Passport configuration for Google
class GooglePassport {
clientId: string;
secretId: string;
constructor() {
this.clientId = googleAppAuth.id;
this.secretId = googleAppAuth.secret;
passport.use(new GoogleStrategy({
clientID: this.clientId,
clientSecret: this.secretId,
callbackURL: "http://localhost:8080/auth/google/callback",
// passReqToCallback : true
profileFields: ['id', 'displayName', 'emails']
},
(accessToken, refreshToken, profile, done) => {
console.log("inside new password google strategy");
process.nextTick( () => {
console.log('validating google profile:' + JSON.stringify(profile));
console.log("userId:" + profile.id);
console.log("displayName: " + profile.displayName);
console.log("retrieve all of the profile info needed");
// this.email = profile.emails[0].value;
profile.ac = accessToken;
profile.re = refreshToken;
return done(null, profile);
});
}
));
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
}
}
export default GooglePassport;