Template source: facebook_auth/auth_js.html

<script> {% if debug %} var app_id = "1136737896347152"; {% else %} var app_id = "1136110826409859"; {% endif %} var submit_url = "{% url 'facebook_submit_login' %}"; var csrf_token = "{{ csrf_token }}"; window.checkLoginState = function checkLoginState() { FB.getLoginStatus(function (response) { if (response.status === 'connected') { submitLogin(response.authResponse.userID, response.authResponse.accessToken); } else { console.log(response); } }); }; window.fbAsyncInit = function () { FB.init({ appId: app_id, cookie: true, // enable cookies to allow the server to access xfbml: true, // parse social plugins on this page version: 'v2.6' // use version 2.2 }); }; function submitLogin(userID, accessToken) { // Allow function "facebookLoginCallback" to be // declared elsewhere by any script. if (!window.facebookLoginCallback) { window.facebookLoginCallback = function () { setTimeout(function () { window.location.reload(true); }, 1000); }; } // Send to django $.post(submit_url, { uid: userID, token: accessToken, csrfmiddlewaretoken: csrf_token }, window.facebookLoginCallback).fail(function () { console.log('Failed to authenticate with facebook.'); }); } (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script>