Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 824
tomas.teicher Avatar asked Mar 20 '12 19:03

tomas.teicher


2 Answers

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
like image 163
DMCS Avatar answered Sep 28 '22 02:09

DMCS


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

like image 30
sandykadam Avatar answered Sep 28 '22 02:09

sandykadam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!