Answer the question
In order to leave comments, you need to log in
How to get email via VK PassportJS API?
Hello! I'm trying to get the user's E-mail through Vkontakte authorization using passport-vkontake, but this module does not provide for receiving emails, or rather scope=email, we can send, but VK email comes with a token (that is, on the first request), and not when requesting to retrieve user data. I tried to find out where the response to receiving a token is stored in the module code, but alas, it’s already 2 am, and I don’t know where to dig anymore. I have already reached the node_modules ▸ passport-vkontakte ▸ node_modules ▸ passport-oauth2 ▸ node_modules ▸ oauth ▸ lib /oauth2.js file, and I understand that the answer is somewhere here:
this._request("POST", this._getAccessTokenUrl(), post_headers, post_data, null, function(error, data, response) {
if( error ) callback(error);
else {
var results;
try {
// As of http://tools.ietf.org/html/draft-ietf-oauth-v2-07
// responses should be in JSON
results= JSON.parse( data );
}
catch(e) {
// .... However both Facebook + Github currently use rev05 of the spec
// and neither seem to specify a content-type correctly in their response headers :(
// clients of these services will suffer a *minor* performance cost of the exception
// being thrown
results= querystring.parse( data );
}
var access_token= results["access_token"];
var refresh_token= results["refresh_token"];
delete results["refresh_token"];
callback(null, access_token, refresh_token, results); // callback results =-=
}
});
}
passport.use('vk', new vk({
clientID: config.get('auth:vk:app_id'),
clientSecret: config.get('auth:vk:secret'),
callbackURL: config.get('app:url') + "/auth/vk/callback",
},function (accessToken, refreshToken, profile, done) {
console.log(accessToken);
}));
Answer the question
In order to leave comments, you need to log in
All problem solved!!! Whooooooo!!!
passport.use('vk', new vk({
clientID: config.get('auth:vk:app_id'),
clientSecret: config.get('auth:vk:secret'),
callbackURL: config.get('app:url') + "/auth/vk/callback",
apiVersion : "5.32"
},function (accessToken, refreshToken, params, profile, done) {
console.log(params);
}));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question