OmniAuth 无效响应 - 更新到 1.9.2 不起作用
你好 我知道这个问题以前曾被问过,但那里的答案对我不起作用。
当重定向回我的网站时,我仍然得到了。
/auth/failure?message=invalid_response
我安装了 ruby 1.9.2p180(2011-02-18 修订版 30909)[x86_64-darwin10.6.0],使用 Rails 3.0.7 并安装了所需的 gems。我在另一个线程上读到,您应该将 pure_json 添加到 gemfile 中才能使其工作。但这也对我没有帮助。
我一无所知...提前致谢
authenticationscontroller
def index
@authentications = current_user.authentications if current_user
end
def create
#render :text => request.env["omniauth.auth"].to_yaml
auth = request.env["omniauth.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
Hi
I know this question have been asked before but the answers there isn't working for me.
I still get the, when redirecting back to my site.
/auth/failure?message=invalid_response
I have ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0] installed, using rails 3.0.7 and the required gems installed. I read on another thread that you should have pure_json added to the gemfile to make it work. But that didn't help me either.
I'm clueless... Thanks in advance
authenticationscontroller
def index
@authentications = current_user.authentications if current_user
end
def create
#render :text => request.env["omniauth.auth"].to_yaml
auth = request.env["omniauth.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以通过在 Gemfile
gem 'omniauth', '0.2.0'
中指定以下内容来使其工作,0.2.6 版本对我不起作用。我还通过 .rvmrc 更新为
rvm use 1.9.2@rails3
。哦,还要确保您已登录 - 请注意,在上面的代码中,您假设current_user
存在。请参阅 Ryan 的 Railscast 第二部分,以允许用户通过 Omniauth 进行创建。我有一个演示在这里工作,但请注意我正在从头开始进行身份验证而不是使用设计。
I was able to get this to work by specifying the following in my Gemfile
gem 'omniauth', '0.2.0'
Version 0.2.6 wouldn't work for me. I also updated by .rvmrc to
rvm use 1.9.2@rails3
. Oh, also make sure you're logged in - do note that in your code above you are assuming thatcurrent_user
exists. See Ryan's Railscast part two for allowing user creation via Omniauth.I've got a demo working here, but do note I'm doing authentication from scratch rather than using Devise.