stevebest / passport-vkontakte

VK.com authentication strategy for Passport and Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't return user email when app has permission "email"

arazumoff opened this issue · comments

Don't return user email when app has permission "email" with get access_token

you must use 5 arguments in callback function or 6 if passReqToCallback: true
Here's an example (params):

passport.use(new VKontakteStrategy({
    clientID:     VKONTAKTE_APP_ID, // VK.com docs call it 'API ID'
    clientSecret: VKONTAKTE_APP_SECRET,
    callbackURL:  "http://localhost:3000/auth/vkontakte/callback"
  },
  function(accessToken, refreshToken, params, profile, done) {
    console.log(params.email);
  }
));
commented

@xxsanekxx this is correct, thanks. This may be closed.

commented

Thank you! It works

commented

@ArtemKolodko BTW vk.com is still some times may not return email (for unknown reason), so you should handle this situation.

commented

@whitecolor maybe, it happens when VK user use cellphone number for login only? VK supports cellphone number or email as username

commented

@ArtemKolodko yeah, it seems you are right.