Answer the question
In order to leave comments, you need to log in
Why does VK authentication fail?
Tell me, good people.
The bottom line is this:
-we have nodeJ
-express module
-passportJS
such a link:
such a config for the passport strategy<a href="/auth/vkontakte">click here</a>
var passport = require('passport');
var app = require('../app.js');
const VKontakteStrategy = require('passport-vkontakte').Strategy;
passport.use(new VKontakteStrategy(
{
clientID: 'APPID', // VK.com docs call it 'API ID', 'app_id', 'api_id', 'client_id' or 'apiId'
clientSecret: 'APPsecret',
callbackURL: "http://localhost:3001/auth/vkontakte/callback",
lang: 'ru'
},
function myVerifyCallbackFn(accessToken, refreshToken, params, profile, done) {
//success
console.log(accessToken);
}
));
app.get('/auth/vkontakte', passport.authenticate('vkontakte', { scope: ['status', 'email', 'friends', 'notify', 'wall'] }));
app.get('/auth/vkontakte/callback',
passport.authenticate('vkontakte', {
successRedirect: '/success',
failureRedirect: '/login'
})
);
TokenError: Code is invalid or expired.
at Strategy.OAuth2Strategy.parseErrorResponse (/home/pavel/Documents/AgNetApp/node_modules/passport-vkontakte/node_modules/passport-oauth2/lib/strategy.js:320:12)
at Strategy.parseErrorResponse (/home/pavel/Documents/AgNetApp/node_modules/passport-vkontakte/lib/passport-vkontakte/strategy.js:176:54)
at Strategy.OAuth2Strategy._createOAuthError (/home/pavel/Documents/AgNetApp/node_modules/passport-vkontakte/node_modules/passport-oauth2/lib/strategy.js:367:16)
at /home/pavel/Documents/AgNetApp/node_modules/passport-vkontakte/node_modules/passport-oauth2/lib/strategy.js:166:45
at /home/pavel/Documents/AgNetApp/node_modules/oauth/lib/oauth2.js:191:18
at passBackControl (/home/pavel/Documents/AgNetApp/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage.<anonymous> (/home/pavel/Documents/AgNetApp/node_modules/oauth/lib/oauth2.js:157:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:975:12)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question