无法使用 Koala 连接 Facebook(使用 Rails)获取 Oauth facebook cookie
我正在使用 Rails 3.0.9。 尝试通过 Facebook 登录我的 (localhost) 网站。
我在登录页面上的初始化参数:
FB.init({
appId : '<%= FB_APP_ID %>',
status : true,
cookie : true,
xfbml : true
});
登录按钮有效,我收到 Facebook 登录弹出窗口,并且可以成功登录 Facebook。 然后发生以下事件:
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {location.href= ...}
我被重定向到所需的位置。 但是 - 无法获取任何“fbs_”或“fbsr_”的 cookie,就像 Oauth 正在寻找的那样: get_user_info_from_cookie(cookies)
我的 cookies = {},那里什么也没有。 有几次,我记得我确实有一些 facebook cookie,我无法重建这种情况,但无论如何,它不包括“fbs_”cookie,只包括其他cookie。
另外,登录后,当我返回浏览器上的 Facebook 选项卡并刷新时,它确实会显示我的 Facebook 页面,但一秒钟后,它会显示一个弹出窗口,显示“您需要登录”。不过,在我的应用程序中,它仍然知道继续将我定向到所需的 href,就像用户登录时所需的那样。
我真的很想听听您是否有任何可以帮助我的信息...:-)
谢谢, 穆兹利。
- 刚刚再次获得一些 Facebook cookie 的场景(仍然不是想要的名称)。获得以下名称:“datr”、“locale”、“locale”、“reg_fb_gate”、“lu”。 但即使是这些我也无法使用 Rails cookies 参数 - cookies["dart"] 返回 null。 cookies 参数仅显示 localhost 主机的 cookie(其中包含我登录时的数据(带有许可)- 站点的常规登录过程。
I'm using Rails 3.0.9.
Trying to login to my (localhost) site through Facebook.
My init params on the login page:
FB.init({
appId : '<%= FB_APP_ID %>',
status : true,
cookie : true,
xfbml : true
});
The login button works, I get the Facebook login popup and I can successfully log in to Facebook.
Then the following event is reached:
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {location.href= ...}
And I'm being redirected to the wanted location.
But - can't get any cookies of "fbs_" or "fbsr_" like the Oauth is looking for at: get_user_info_from_cookie(cookies)
My cookies = {}, nothing there.
In a few occasions, I recall I did have some facebook cookies there, I can't reconstruct such case, but anyway, it didn't include the "fbs_" ones, only others.
Also, after logging in, when I go back to Facebook tab on the browser and refresh, it does show me my Facebook page, but after a second, it shows a popup says "you need to log in". In my app though, it still knows to keep directing me to the wanted href, like needed when a user is logged in.
I would really love to hear if you have anything that can help me... :-)
Thanks,
Moozly.
- Just got the scenario with some Facebook cookies again (still not by the wanted names). Got the following names: "datr", "locale", "locale", "reg_fb_gate", "lu".
But even to these I can't get to with the Rails cookies param - cookies["dart"] returns null.
cookies param only shows the cookies with the host of localhost (which contains data when I'm logging in (with Clearance) - the regular login procedure to site.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是想更新说我已经解决了我的问题:
我已在 init 中添加了参数:
oauth : true
:显然,添加参数时存在错误
js.src,所以我删除了它们(!),问题就解决了:
这为我解决了cookie问题!
Just wanted to update to say that I had solved my problem:
I had added to the init the param:
oauth : true
:Apparently, there is a bug with adding the parameters added in
js.src, so I removed them(!) and problem was solved:
That solved the cookies problem for me!
如果您想使用 localhost 进行 facebook 开发,请将“127.0.0.1 localhost.local”记录添加到您的 /etc/hosts 文件中,更改 Developers.facebook.com 中应用程序设置中的域并将浏览器指向此 url - 它可以完美运行
if you want to use localhost for facebook development, add "127.0.0.1 localhost.local" record to your /etc/hosts file, change domain in application settings in developers.facebook.com and point browser to this url - it works flawlessly