#_ = _通过Facebook添加到URL [英] #_=_ added to URL by facebook

查看:185
本文介绍了#_ = _通过Facebook添加到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试指定一个由FB指定的redirect_uri,但是没有不能工作。

删除符号的Javascript解决方法没有帮助。我试过一切没有结果。

有关如何解决这个问题的任何指针?



我的设置:

  gem'rails','3.0.11'
gemdevise,'1.5.2'
gemomniauth,'1.0。 1'
gem'omniauth-facebook','1.0.0rc2'

模块Facebook
CONFIG = YAML.load_file(Rails.root.join(config / facebook.yml ))[Rails.env]
FB_APP_ID = CONFIG ['app_id']
FB_APP_SECRET = CONFIG ['secret_key']
end

Rails.application.config提供者:Facebook,Facebook :: FB_APP_ID,Facebook :: FB_APP_SECRET,
:scope => 'offline_access,email,publish_stream',
:display => 'touch'
end


解决方案

#_ = _ 片段是由Facebook故意添加的,如会话更改重定向行为。在您的请求中显式设置redirect_uri涉及到这个问题,但是显然有一个错误,即使指定了redirect_uri,仍然存在不需要的碎片。



假设这个bug是不解决,解决方法可能是使用Javascript替换散列位置:

  window.location.hash =

这不代替实际的哈希字符,但会摆脱以后的一切。


After connecting to my Rails app via Facebook I have #_=_ added on to my URL.

I tried specifying a redirect_uri as specified by FB but it didn't work.
Javascript workaround to remove the symbols doesn't help. I tried everything with no results.
Any pointers on how to solve this?

My setup:

gem 'rails', '3.0.11'
gem "devise", '1.5.2'
gem "omniauth", '1.0.1'
gem 'omniauth-facebook', '1.0.0rc2'

module Facebook
 CONFIG = YAML.load_file(Rails.root.join("config/facebook.yml"))[Rails.env]
 FB_APP_ID = CONFIG['app_id']
 FB_APP_SECRET = CONFIG['secret_key']
end

Rails.application.config.middleware.use OmniAuth::Builder do    
 provider :facebook, Facebook::FB_APP_ID, Facebook::FB_APP_SECRET,
 :scope => 'offline_access, email, publish_stream',
 :display => 'touch'
end

解决方案

The #_=_ fragment is being intentionally added by Facebook as described under Change in Sessions Redirect Behavior. Explicitly setting the redirect_uri in your request allegedly takes care of this problem, but there's apparently a bug that persists the unwanted fragment even when the redirect_uri is specified.

Assuming this bug isn't resolved, a workaround may be to replace the hash location using Javascript:

window.location.hash = ""

This doesn't replace the actual hash character, but will get rid of everything following it.

这篇关于#_ = _通过Facebook添加到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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