Facebook auth对话框(JS SDK)返回空白屏幕 [英] Facebook auth dialog (JS SDK) returns blank screen

查看:382
本文介绍了Facebook auth对话框(JS SDK)返回空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个rails应用程序,并试图通过Facebook JS SDK实现登录。已经丢失了Omniauth ...(



无论如何,会弹出对话框,用户提供登录信息,但是它会重定向到 https://www.facebook.com/connect/window_comm.php?_id=some-string&_relation=opener&auth_token=some-big-string ,一个空白屏幕,不要关闭。



如果我手动关闭,然后刷新我的页面,我可以看到登录发生。


一个好奇的事情是,在第一次登录时,当需要权限时,一切都按预期工作,弹出关闭后授予或拒绝权限。



在Chrome,FF,Safari和Opera上测试一致的行为。



如果我在Chrome上调试空白的重定向页面,则会出现两个错误: / p>

1)不安全的JavaScript尝试使用URL访问框架http://来自框架的URL https:// something。域名,协议和端口必须匹配。(注意http x https ...)



2) window_comm.php :7Uncaught TypeError:无法调用未定义的方法_recv



以下是相关代码:

 < script> 
window.fbAsyncInit = function(){
FB.init({
appId:'my-app-id',
status:true,
channelURL:' http:// localhost:3000 / channel.html',
cookie:true,
oauth:true,
xfbml:true
});

FB.Event.subscribe('auth.login',function(response){
window.location.reload();
});
};
(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/pt_BR/all.js
fjs.parentNode。 insertBefore(js,fjs);
}
(document,'script','facebook-jssdk'));
< / script>
< div class =fb-login-buttondata-show-faces =truedata-width =400data-max-rows =1perms =offline_access> / DIV>

非常感谢任何光线...驱动我坚果! =(



编辑:这可能是Facebook上的错误,因为它是从http重定向到https?

解决方案

只答复Q.1)。 Facebook的新要求: -




  • 切换到Oauth2.0以使用SSL(ie)获取token_access

  • :https://)进行身份验证(因此是跨域问题)



另外,我一般从下面的代码开始找出登录过程中可能的用户状态。这意味着在测试阶段点击任何东西和一切。

  FB.Event.subscribe('auth.authResponseChange',function(response ){
alert('会话的状态是:'+ response.status);
});


I'm setting up a rails app and trying to implement login via Facebook JS SDK. Missing Omniauth already... :(

Anyway, what happens is that the dialog pops up, the user provides the login info, but then it redirects to https://www.facebook.com/connect/window_comm.php?_id=some-string&_relation=opener&auth_token=some-big-string, a blank screen. The pop-up doesn't close.

If I close it manually, though, and then refresh my page, I can see the login happened.

A curious thing is that on the first login, when permissions are asked for, everything works as expected, with the pop-up closing after permissions are granted or denied.

Tested on Chrome, FF, Safari and Opera. Consistent behaviour.

If I debug the blank redirect page on Chrome, there are two errors:

1) Unsafe JavaScript attempt to access frame with URL http://something from frame with URL https://something. Domains, protocols and ports must match. (note http x https...)

2) window_comm.php:7Uncaught TypeError: Cannot call method '_recv' of undefined

Here's the relevant code:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'my-app-id',
      status     : true,
      channelURL : 'http://localhost:3000/channel.html',
      cookie     : true,
      oauth      : true,
      xfbml      : true
    });

    FB.Event.subscribe('auth.login', function(response) {
      window.location.reload();
    });
  };
  (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/pt_BR/all.js"
    fjs.parentNode.insertBefore(js, fjs); 
    } 
    (document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1" perms="offline_access"></div>

Thanks a lot for any light on this... Driving me nuts! =(

Edit: Can it be a bug on Facebook, since it is redirecting from http to https?

解决方案

This answers Q.1) only. Facebook new requirements:-

  • switching to Oauth2.0 to fetch token_access
  • using SSL (ie: https://) to authenticate (hence the cross domain issues)

Also, I'd generally start with the code below to figure out the possible user state during the login process. That means clicking on anything and everything during testing phase.

FB.Event.subscribe('auth.authResponseChange', function(response) {
    alert('The status of the session is: ' + response.status);
});

这篇关于Facebook auth对话框(JS SDK)返回空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆