顯示驗證彈出我在http://apps.facebook.com/insideny/Facebook的JS SDK返回XSS錯誤和「user_denied」應答,而不上的FB.login
一個FB帆布應用直到最近我用一個錨鏈接發送給用戶的OAUTH登錄流。
由於我實現了Facebook的Javascript SDK我已經使用以下邏輯:
1)初始化FB API
FB.init({
appId: 'XXXXXXXXXXXXXX',
xfbml: true,
cookie: true,
oauth : true,
channelUrl: 'http://www.niteflymobile.com/insideny/channel.html' },
{scope: 'email'});
2)檢查登錄狀態
FB.getLoginStatus(function(response) { ... })
3)如果用戶被發現登錄(response.status ==「connected」),則設置一個正確的cookie並重定向到登錄頁面。
4)這裏是哪裏出了問題如果response.status!=「連接」(通常返回新用戶「NOT_AUTHORIZED」)再火來的FB.login調用(函數(響應){... })。
4a)中的FB.login回來與2個錯誤的以下類型:
「不安全的JavaScript嘗試與URL static.ak.fbcdn.net/connect/xd_proxy.php?version=3 &訪問幀ERROR_REASON = user_denied &誤差= ACCESS_DENIED & ERROR_DESCRIPTION = +的用戶拒絕+ + +您的請求。#CB = f22684144 &原點= HTTP%3A%2F%2Fwww.niteflymobile.com%2Ff185641ad8 &關係=開罐器&運輸= PostMessage的&幀= f39056acd8來自帶有URL的框架www.niteflymobile.com/insideny/#。域,協議和端口必須匹配。「
(HTTP://從兩個環節去除,以符合新的用戶,這樣的規則)
,此外返回的對象,我寫信給控制檯包含null authResponse和狀態爲「未知」,而不是到「未經授權」就是剛纔的事。
這裏的核心問題是激發授權的彈出窗口,但是是空白的,並且在沒有任何用戶交互的情況下快速關閉。
任何想法/幫助/見解都會非常感謝,因爲我現在已經對此感到頭疼了很多,我懷疑它是一個愚蠢的錯誤,我不能看到,因爲我太深了。
我剛剛刪除了沙箱模式,可能是一個可能的原因?
完整代碼BELOW:
$('.fb_link').click(function() {
FB.init({appId: 'XXXXXXXXXX', xfbml: true, cookie: true, oauth : true, channelUrl: 'http://www.niteflymobile.com/insideny/channel.html' },{scope: 'email'});
//setup fb login check
FB.getLoginStatus(function(response) {
if(response) {
console.log(response);
if(response.status == "connected") {
alert(response.status);
alert(response.authResponse.userID+"preajax");
//jquery cookie write
$.cookie('fbID', response.authResponse.userID, { expires: 29, path: '/' });
//secondary cookie write using only javascript
createCookie('fbID', response.authResponse.userID, 29);
//bandaid to fire ajax to set cookie on server side if the js side fails
var fbID_check = readCookie('fbID');
if(fbID_check) {
alert("fbID cookie set "+fbID_check);
window.location = "http://apps.facebook.com/insideny/";
}
else {
url_vars = "fbID="+response.authResponse.userID;
$.ajax({
type: "POST",
url: "set_fb_cookie.php",
data: url_vars,
success: function(data){
alert(data + "passed back from ajax");
var fbID_check_2 = readCookie("fbID");
alert(fbID_check_2 + "read from cookie");
window.location = "http://apps.facebook.com/insideny/";
}
});
return false;
}
alert(response.authResponse.userID+"postajax");
}
else {
FB.login(function(response) {
alert('here');
console.log(response);
});
}
}
})
})
UPDATE 8.12 @菲利普-布拉姆
試圖用相同的效果以下代碼(彈出但是空白和關機)
$('.fb_link').click(function() {
FB.init({appId: 'XXXXXXXXXXXXX', xfbml: true, cookie: true, oauth : true, channelUrl: 'niteflymobile.com/insideny/channel.html'; },{scope: 'email'});
FB.login(function(response) {
console.log(response); })
})
你可以發佈完整的代碼,而不僅僅是解釋嗎? – Einacio
完整代碼已添加 –
您是否已經爲位於開發人員應用程序中的應用程序啓用了oauth 2.0? –