Answer the question
In order to leave comments, you need to log in
How to get gmail api when registering passport-google-oauth?
There is authorization using assport-google-oauth
module.exports = function(passport) {
passport.serializeUser(serializeUser);
passport.deserializeUser(deserializeUser);
passport.use(new GoogleStrategy({
clientID : configAuth.googleAuth.clientID,
clientSecret : configAuth.googleAuth.clientSecret,
callbackURL : configAuth.googleAuth.callbackURL,
}, authCallback));
};
/**
* Authentication callback
* @return void
*/
function authCallback(token, refreshToken, profile, done) {
process.nextTick(function() {
console.log(profile) // тут данные пользователя. без данных gmail
return done(null, profile);
});
}
//router.js
app.get('/auth/google', passport.authenticate('google', {
scope : ['profile', 'email', 'https://www.googleapis.com/auth/gmail.readonly']
}));
app.get('/auth/google/callback', passport.authenticate('google', {
failureRedirect : '/',
successRedirect: '/home'
}));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question