FB JDKで私のWebサイトでFBログインを有効にしました。私はそれを使用すると、それは完全に動作します:ダイアログウィンドウが開き、私は許可し、authResponse
は期待どおりです。別のユーザーが(アプリをまだ承認していないがFBにログインしている)ユーザーを使用すると、すぐにログインダイアログが表示され、即座に表示されなくなり、応答オブジェクトのステータスはnot_authorized
になります。なぜダイアログがユーザーに権限を与えるように要求していないのか、という考えはありますか?私のレイアウト(HAML)でfb.Login()ウィンドウがすぐに閉じて「not_authorized」を返します
:
%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));
ログインリンク:CoffeeScriptので
%a{href: '#', onclick: 'FB.login(window.reportFBstatus, {scope: "user_about_me"})'}
:私のために働いた
window.reportFBstatus = (response) ->
$.ajaxSetup({
headers:
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
})
console.log response # always shows status=not_authorized for other users
if response.status is 'connected'
auth = response.authResponse
$.post('/login', {fb_id: auth.userID, fb_token: auth.accessToken}, (data) ->
window.currentUser = data
)
私は同じ問題が発生しています。根本原因を特定できません –