Rails 3:Omniauth-Facebook:不会在弹出窗口中加载

发布于 2024-12-25 08:09:07 字数 525 浏览 4 评论 0原文

我正在使用omniauth-facebook 来处理Facebook 身份验证,它运行得非常好。然而,在弹出窗口中打开 Facebook 对话框(在文档中看起来非常简单)对我来说不起作用。

devise.rb:

require "omniauth-facebook"
config.omniauth :facebook, "xxx", "yyy", { :scope => 'publish_stream,publish_actions,email,read_stream,offline_access', :display => 'popup' }

但是,它没有在弹出窗口中加载。相反,它会转移到 facebook.com,然后再返回。也就是说,加载的 URL 包含“display=popup”,因此代码可以正确读取,只是没有在模式中加载。

这感觉像是 Javascript 问题吗?我不确定 Omniauth 使用什么来处理模态/iframe/等。在这起作用之前我应该​​包含一些东西吗?

提前致谢!

I am using omniauth-facebook to handle Facebook auth, and it's working wonderfully. However, opening the facebook dialogs in a popup, which appear quite simple in the documentation, isn't working for me.

devise.rb:

require "omniauth-facebook"
config.omniauth :facebook, "xxx", "yyy", { :scope => 'publish_stream,publish_actions,email,read_stream,offline_access', :display => 'popup' }

However, it's not loading in a popup. Rather, it's moving over to facebook.com and then back. That said, the URL that loads includes "display=popup", so the code is being read properly, it's just not loading in a modal.

This feels like a Javascript issue? I am not sure what Omniauth uses to handle modals / iframes / etc. Is there something I should be including before this will work?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫林﹌晚霞¤ 2025-01-01 08:09:07

经过数小时的研究和反复试验,我找到了一个可行的解决方案。我觉得必须有一个更加集成的解决方案,但我不知道。

这个 jQuery 将触发当前上方的 fb auth 窗口:

$('a.fb-auth').click(function(e) {
var width = 600, height = 400;
var left = (screen.width / 2) - (width / 2);
var top = (screen.height / 2) - (2 * height / 3);
var features = 'menubar=no,toolbar=no,status=no,width=' + width + ',height=' + height + ',toolbar=no,left=' + left + ',top=' + top;
var loginWindow = window.open('/users/auth/facebook', '_blank', features);
loginWindow.focus();
e.preventDefault();
return false;
});

在您的回调页面上:(

<script>
window.opener.location = "/";
window.close(); 
</script>

或者您希望在父页面上发生的任何情况)

After hours and hours of research and trial and error, I found a solution that works. I feel like there must be a more integration solution, but I don't know it.

This jQuery will trigger the fb auth window above the current:

$('a.fb-auth').click(function(e) {
var width = 600, height = 400;
var left = (screen.width / 2) - (width / 2);
var top = (screen.height / 2) - (2 * height / 3);
var features = 'menubar=no,toolbar=no,status=no,width=' + width + ',height=' + height + ',toolbar=no,left=' + left + ',top=' + top;
var loginWindow = window.open('/users/auth/facebook', '_blank', features);
loginWindow.focus();
e.preventDefault();
return false;
});

And on your callback page:

<script>
window.opener.location = "/";
window.close(); 
</script>

(or whatever you want to happen to the parent page)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文