我正在使用ruby,sinatra和考拉宝石为facebook创建一个应用程序。
当我重定向到/ auth / facebook它会执行所需的操作,但是它首先重定向到具有此矩形的页面,然后转到auth对话框。我认为这对最终用户来说非常难看。如何删除这个奇怪的重定向?
代码:
#This function defines a get and post route with the same parameters.
def get_or_post(path, opts={}, &block)
get(path, opts, &block)
post(path, opts, &block)
end
get "/auth/facebook/?" do
redirect authenticator.url_for_oauth_code(:permissions => FACEBOOK_SCOPE)
end
get_or_post '/auth/facebook/callback/?' do
session[:access_token] = authenticator.get_access_token(params[:code])
update_user()
redirect '/'
end
答案 0 :(得分:1)
我猜你在画布iframe中进行重定向?那当然会尝试在iframe中显示auth对话框,并且auth对话框不希望以任何类型的(i)帧显示。
所以不要重定向(你不能指定目标),而是使用JavaScript来“重定向” - 让你的脚本输出一个小的HTML文档,它基本上只包含一行JavaScript,使用
top.location.href = '{auth dialog URL goes here}';
在当前浏览器窗口的顶部框架中加载新网址。