trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
265 stars 141 forks source link

Missing E-Mail when authenticating via Vkontakte #80

Open slavafomin opened 8 years ago

slavafomin commented 8 years ago

I've implemented the VK oAuth 2 authentication this way in config/passport.js:

var _ = require('lodash');
var _super = require('sails-auth/config/passport');

var returnUrl = encodeURIComponent('/');

_.merge(exports, _super);
_.merge(exports, {
  passport: {
    vkontakte: {
      name: 'Vkontakte',
      protocol: 'oauth2',
      strategy: require('passport-vkontakte').Strategy,
      options: {
        clientID: '...',
        clientSecret: '...',
        callbackURL: 'http://localhost:1337/auth/vkontakte/callback?next=' + returnUrl,
        scope: ['email']
      }
    }
  }
});

However, the E-Mail is missing from the created user profile. What could be the problem? VK should return E-Mail cause it supports email scope. Here's the issue on the provider repo: https://github.com/stevebest/passport-vkontakte/issues/16.

iam-medvedev commented 8 years ago
passport.use(new VKontakteStrategy({...},
    function(req, accessToken, refreshToken, params, profile, done) {
        // ! use params.email !
    }
});
slavafomin commented 8 years ago

Thank you for a code snippet @iam-medvedev , however I do not have such a code in my project. I think that sails-auth is encapsulating this functionality somewhere. Is it possible to work around this issue in my application realm or do we need to update the sails-auth itself in order to achieve this?

Thank you!