Open roy-key opened 5 years ago
Try to config https server for your app
I am having the same problem. The error is not forwarded to the failureHandler if the user presses cancel("Not now"). Is there any workarounds for this scenario?
Did someone found a solution to this issue?
Does https fix the failureRedirect
?
Here is the issue on my side:
When I enter invalid code in the callback for example http://localhost:3000/auth/facebook/callback?code=some_invalid_code
I'm not redirected to the failureRedirect
link but instead, an error with status 500 is thrown and a message which says FacebookTokenError: Invalid verification code format.
. I want to show this message on the login page.
@shalachev I have same problem on HTTPS. In my opinion the HTTP(s) protocol does not matter.
These errors are passed via "next(err)" function (which is part of express js functionality). I think we need to treat them as exceptions, because failureRedirect is not used.
So, to catch them before main expressjs error handler middleware (err, req, res, next), we can catch them by passing error handler as next route function.
Sorry for my bad English.
For example:
const facebookCallback = passport.authenticate('facebook', {successRedirect: '/?pass', failureRedirect: '/?fail'});
const passportErrorHandler = (err, req, res, next) => {
// Here you can handle passport errors
console.error(`Passport error: ${err.message}`);
res.redirect('/');
};
router.get('/facebook/callback', facebookCallback, passportErrorHandler);
@roy-key Have you got any idea about the error you were getting from FB? I'm talking about the error 1349003
. It's driving me nuts!! It appears that I get that error ONLY IF the user un-checks ONLY SOME of its groups from the permissions list. And the strange thing is that after that, if the user tries to login again, the app gets automatically authenticated with ALL permissions in all groups! What the hell!
Hi. As i'm trying to handle where a user clicks 'Cancel' on the Facebook prompted modal, instead of being redirect to the failureRedirect, I'm getting this:
The URL is which displays this error trace:
This is my settings (very similar to the example in the documentation: http://www.passportjs.org/docs/facebook/
This is my sample: server.js
login.html:
success.html:
Running on:
Expected: be redirected to
localhost:3000/failure
[ notice, thesuccessRedirect
working great, i'm redirected tohttp://localhost:3000/success#_=_
]Notice: the example here: https://github.com/passport/express-4.x-facebook-example produces the same outcomes.