We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello.
I use authorization method - https://www.passportjs.org/packages/passport-vkontakte/
And authorization works for me, but sometimes an error pops up and the application crashes.
What could be the problem? Here is the code.
app.get( '/auth/vk', (_0, res, next) => { const now = Date.now(); if (now - lastVkAuth < 1000) { res.redirect('/'); } else { lastVkAuth = Date.now(); next(); } }, passport.authenticate('vkontakte', { failureRedirect: '/', session: false, }), ); app.get( '/auth/vk/return', passport.authenticate('vkontakte', { failureRedirect: '/', session: false, }), async (req, res) => { if (req.user && req.authInfo) { const expiresIn = 60 * 60 * 24 * 180; // 180 days const token = jwt.sign(req.user, config.auth.jwt.secret, { expiresIn }); res.cookie(config.auth.tokenKey, token, { maxAge: 1000 * expiresIn }); // Set referrer if it is define in cookies const { refId } = req.cookies; if (refId && req.authInfo.isRegistered) { await repositories.users.setReferrer(req.user.id, refId); res.clearCookie('refId'); } } res.redirect('/'); }, );
Error screen - https://ibb.co/mJB1JsY
The text was updated successfully, but these errors were encountered:
How to handle TokenError ?
Passing err to the argument and the if(err) condition didn't help anywhere.
Sorry, something went wrong.
It sounds like your token is just expiring. You would need to refresh it with something like passport-oauth2-refresh.
No branches or pull requests
Hello.
I use authorization method - https://www.passportjs.org/packages/passport-vkontakte/
And authorization works for me, but sometimes an error pops up and the application crashes.
What could be the problem? Here is the code.
Error screen - https://ibb.co/mJB1JsY
The text was updated successfully, but these errors were encountered: