J
J
JIakki2016-02-27 20:02:50
gmail
JIakki, 2016-02-27 20:02:50

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'
  }));

How can I get the API?
Thanks for the answer

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question