How to open facebook login dialog in the same window instead of popup window?

32,551

Solution 1

See: https://developers.facebook.com/docs/reference/dialogs/oauth/

Rather than using the FB.login(), just add a link to your page like this:

<a href="https://www.facebook.com/dialog/oauth/?client_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URL&state=YOUR_STATE_VALUE&scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES">LOGIN!</a>

Facebook will then log the user in and redirect them back to your URL with some goodies on the querystring:

YOUR_REDIRECT_URI?
    error_reason=user_denied
   &error=access_denied
   &error_description=The+user+denied+your+request.
   &state=YOUR_STATE_VALUE

Solution 2

As per the Facebook documentation you can use display=page which will open in same browser window.

Share:
32,551
tomas.teicher
Author by

tomas.teicher

Updated on July 09, 2022

Comments

  • tomas.teicher
    tomas.teicher almost 2 years

    I have website where users can login with their Facebook account. I am using javascript FB.login method to display Facebook login dialog. By default, it triggers displaying new popup window. Many users have forbidden popups in their browser. How to force facebook login dialog to be displayed in the same window where the user clicked on Login button? I can see that it works on this website

    When user click on Login button, he is redirected to facebook. After he login to FB, he is redirected back to the original website. Everything in the same browser tab.