I have a Facebook Page tab app. For a user who is not logged in, I want to:
- Detect if user is not logged in
- If not logged in, automatically direct user to login
My current approach is to use FB Javascript SDK (in preference to server-side authentication flow):
- On page load, run
FB.getLoginStatus
to check user status - If user is not logged in, run
FB.login
to invoke OAuth dialog
Problem:
FB.login
creates a pop-up dialog (prefer if within Page Tab iframe)- This pop-up dialog is blocked if
FB.login
is not invoked from a button (I would really like to avoid having the user click a button; so would really like to invoke it automatically, when I find a user that is not logged in)
FB.login without user interaction -> blocked popup
The Auth dialog won’t work inside an iframe, it’s designed that way.
If the automatic call of the login dialog is your most important requirement – then use JavaScript to redirect to the Auth dialog URL, and redirect back to your page/app Facebook address afterwards. See section “Client-side authentication without the JS SDK” here: https://developers.facebook.com/docs/authentication/client-side/