Tôi đã bật đăng nhập FB trên trang web của mình bằng FB JDK. Khi tôi sử dụng nó, nó hoạt động hoàn hảo: cửa sổ hộp thoại mở ra, tôi cho phép và authResponse
như mong đợi. Khi người dùng khác sử dụng nó (người chưa ủy quyền ứng dụng nhưng đã đăng nhập vào FB), hộp thoại đăng nhập sẽ xuất hiện trong giây lát, và ngay lập tức biến mất, và đối tượng phản hồi có trạng thái not_authorized
. Bất kỳ ý tưởng nào về lý do tại sao hộp thoại có thể không yêu cầu người dùng ủy quyền?fb.Login() cửa sổ đóng ngay lập tức và trả về 'not_authorized'
Trong cách bố trí của tôi (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));
Các liên kết đăng nhập:
%a{href: '#', onclick: 'FB.login(window.reportFBstatus, {scope: "user_about_me"})'}
Trong Coffeescript:
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
)
Tôi đang gặp sự cố tương tự. Không thể tìm ra nguyên nhân gốc –