I have FB login enabled on my site with FB JDK. When I use it, it works fine: a dialog box opens, I enable, and authResponse - as expected. When another user uses it (who has not yet authorized the application, but has been registered in FB), the login dialog appears for a short second and instantly disappears, and the response object has the status not_authorized . Any ideas as to why the dialog might not ask the user for authorization?
In my layout (Haml):
%body #fb-root :javascript window.fbAsyncInit = function() { FB._https = false; FB.init({ appId : <App ID> status : true, cookie : true, oauth : true, xfbml : true }); FB.getLoginStatus(function(response) { if(window.reportFBstatus) { reportFBstatus(response); } }, true); }; // Load the SDK (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document));
Login link:
%a{href: '#', onclick: 'FB.login(window.reportFBstatus, {scope: "user_about_me"})'}
In Coffeescript:
window.reportFBstatus = (response) -> $.ajaxSetup({ headers: 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') }) console.log response
Rafi
source share