Shubham Singla Shubham Singla - 1 year ago 64
Node.js Question

Google oauth not returning email passport authentication

I am trying to make a sign in with google button using passport module of node js. i am trying to get persons email id, name , profile pic. I am trying to download pic to local server. Google is not returning email id even after adding 'email' to scope and nor the returned link for profile pic is working. I have looked into various answers to this question but all says to include .it has been deprecated now. As per google documentation new scope parameter is email
below is my code
Any help is appreciated

passport.use(new GoogleStrategy({

clientID : configAuth.googleAuth.clientID,
clientSecret : configAuth.googleAuth.clientSecret,
callbackURL : configAuth.googleAuth.callbackURL,
function(token, refreshToken, profile, done) {

// make the code asynchronous
// User.findOne won't fire until we have all our data back from Google
process.nextTick(function() {

// try to find the user based on their google id
User.findOne({ '' : }, function(err, user) {
if (err)
return done(err);

if (user) {

// if a user is found, log them in
return done(null, user);
} else {
// if the user isnt in our database, create a new user
var newUser = new User();
// set all of the relevant information =; = profile.token; = profile.displayName; = profile.emails[0].value; // pull the first email = profile._json.picture;
console.log('url is');
console.log('error in dp');
console.log('Profile Picture downloaded');

// save the user {
if (err)
throw err;
return done(null, newUser);



app.get('/connect/google', passport.authorize('google', { scope : ['profile', 'email'] }));

// the callback after google has authorized the user
passport.authorize('google', {
successRedirect : '/profile',
failureRedirect : '/'


module.exports = function(username, uri, callback){
var destination;

.on('close', function(){
console.log("saving process is done!");

Answer Source

I had the same problem and wrote the scope in this way:

app.get('/connect/google', passport.authenticate('google', {
    scope: [

And you will get the email:

function(accessToken, refreshToken, profile, done) {

I hope this helps you.