I think I'm facing a bug, maybe somebody knows something about it:
When using FB login (version 14, but lower also doesn't work) with the scopes 'business_management,whatsapp_business_management,catalog_management', then the FB user has to enter his 2FA code in the FB login popup.
What happens is that the popup opens, then it immediately redirects to https://www.facebook.com/security/twofactor/reauth/?twofac_next=https%3A%2F%2Fwww.facebook.com%2Fv14.0%2Fdialog%2Foauth%3Fencrypted_query_string=XXXX&type=avoid_bypass&app_id=0&save_device=0, where it asks for the 2FA code.
When this redirect happens, the callback from the FB login is already triggered (before I enter the code) but obviously it doesn't have an authResponse yet, so the response is
{
"authResponse": null,
"status": "unknown"
}
When I then enter the code and go through all steps in the login popup successfuly and it closes itself afterwards, I don't get any response in my app anymore. Also when calling FB.getLoginStatus({...}, true) afterwards, I still get status="unknown" and authResponse=null.
The same happens for all events like auth.login, auth.authResponseChange and auth.statusChange. They won't get triggered anymore when the popup has made the roundtrip to the 2FA auth form.
To make it work, I can open the login popup again in the same session, where it does NOT ask me again for the 2FA code, thus also not immediately triggering the callback. It then correctly triggers the callback at the completion of the login popup process with the correct response of
{
"authResponse": {...},
"status": "connected"
}
and all events are fired correctly when stuff changes.
What I expect: The callback is fired only once at the very end of the popup flow (when hitting the OK button and it closes itself), like it does without 2FA auth in between.
The call I make is:
FB.login((response) => {
console.log(response);
}, {
scopes: 'business_management,whatsapp_business_management,catalog_management',
return_scopes: true,
});
Thanks for any advise
Edit: here is the discussion on facebook: https://developers.facebook.com/community/threads/619130686264369/?post_id=619130689597702