Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect the url after logging into Facebook?
    text
    copied!<p>I have created a django application with a Facebook connect to the application. Now when i click on the Facebook login button, the oauth page pop ups. When i give the username n password, it gets closed without actually redirecting the page to any page. But when i took FB page in a new tab, i could see the FB logged in page of that user. So the login is working perfect, but i dont understand where to give the page redirection after it gets authenticated. Can somebody help me to solve this. This is how i set in my settings page ? I couldnt find any callback url to be set in the options.</p> <pre><code>App ID xxxx API Key xxxx App Secret xxx Site URL http://localhost:8080/redirect_url/ Site Domain localhost Canvas Page http://apps.facebook.com/registrationforms/ Canvas URL http://apps.facebook.com/registrationforms/ Secure Canvas URL Canvas FBML/iframe iframe </code></pre> <p>The code for login : This piece of code is inserted in the registrationForm html page(login) :</p> <pre><code>{% load facebookconnect %} {% facebook_connect_login_button %} {% facebook_connect_script %} </code></pre> <p>and the facebookconnect.py code is :</p> <pre><code>from django import template from django.conf import settings from django.core.urlresolvers import reverse register = template.Library() class FacebookScriptNode(template.Node): def render(self, context): return """ &lt;script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; FB.init("%s", "%s"); function facebook_onlogin() { var uid = FB.Facebook.apiClient.get_session().uid; var session_key = FB.Facebook.apiClient.get_session().session_key; var expires = FB.Facebook.apiClient.get_session().expires; var secret = FB.Facebook.apiClient.get_session().secret; var sig = FB.Facebook.apiClient.get_session().sig; fb_connect_ajax(expires, session_key, secret, uid, sig); } function fb_connect_ajax(expires, session_key, ss, user, sig) { var post_string = 'expires=' + expires; post_string = post_string + '&amp;session_key=' + session_key; post_string = post_string + '&amp;ss=' + ss; post_string = post_string + '&amp;user=' + user; post_string = post_string + '&amp;sig=' + sig; $.ajax({ type: "POST", url: "%s", data: post_string, success: function(msg) { window.location = '%s'; //.reload() } }); } &lt;/script&gt; """ % (settings.FACEBOOK_API_KEY, reverse('xd_receiver'), reverse('facebook_connect_ajax'), settings.LOGIN_REDIRECT_URL) def facebook_connect_script(parser, token): return FacebookScriptNode() register.tag(facebook_connect_script) class FacebookLoginNode(template.Node): def render(self, context): return "&lt;fb:login-button onlogin='facebook_onlogin();'&gt;&lt;/fb:login-button&gt;" #return "&lt;fb:login-button onclick="openPopup('https://graph.facebook.com/oauth/authorize?client_id=a0acfd122e64fc21cfa34d47369f0c97&amp;redirect_uri=http://mysite.com/mypage&amp;display=popup');"&gt;&lt;/fb:login-button&gt;" def facebook_connect_login_button(parser, token): return FacebookLoginNode() register.tag(facebook_connect_login_button) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload