我正在使用Omniauth和强制/ auth/facebook在弹出窗口中显示(使用JS).[而不是一个新窗口 - 用户友好程度低得多]
问题是:Omniauth加载FB网址
display=page
Run Code Online (Sandbox Code Playgroud)
而不是我想要的:
display=popup
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何改变Omniauth用于Facebook的参数?
谢谢
我正在按照Ryan Bate的指示使用Omniauth建立第三方认证,除了我正在尝试使用Facebook而不是Twitter,他在RailsCast 235中设置了它.
安装omniauth-facebook gem后,设置初始化程序
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'APP_ID', 'APP_SECRET'
end
Run Code Online (Sandbox Code Playgroud)
我应该可以去localhost:3000/auth/facebook并获得Facebook登录(尽管它最终不会起作用,因为我们还没有设置回调网址)但是,当我去那个网址时,我收到这个错误
{
"error": {
"message": "Error validating application.",
"type": "OAuthException",
"code": 101
}
}
Run Code Online (Sandbox Code Playgroud)
并且url实际上变为
https://graph.facebook.com/oauth/authorize?response_type=code&client_id=APP_ID&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Ffacebook%2Fcallback&scope=email%2Coffline_access
Run Code Online (Sandbox Code Playgroud)
在我的应用程序上,我已经设置了Devise并按照Devise wiki上的说明整合了Facebook授权https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
谁能告诉我问题可能是什么?
对错误消息进行谷歌搜索显示,最近几周有不少人遇到过这个问题,但却找不到任何有解决方案的人

在这个Q&A线程之后,我得到了它,以便用户可以使用弹出窗口通过Omniauth Facebook策略登录.这是我的代码:
视图:
<%= link_to("Sign in with Facebook", "/auth/facebook", :id => "signin",
:data => {:width => 600, :height => 400}) %>
Run Code Online (Sandbox Code Playgroud)
application.js中:
function popupCenter(url, width, height, name) {
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,left="+left+",top="+top);
}
$(document).ready(function() {
$('a#signin').click(function(e) {
popupCenter($(this).attr('href'), $(this).attr('data-width'), $(this).attr('data-height'), 'authPopup');
e.stopPropagation();
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
sessions_controller.rb:
def create
user = AuthProviders::FacebookUser.find_or_create_user_from(auth_hash)
session[:current_user_id] = user.id
@return_to = origin || root_url
render :callback, :layout => false
end
protected
def auth_hash
request.env['omniauth.auth'] …Run Code Online (Sandbox Code Playgroud)