OmniAuth 无效响应 - 更新到 1.9.2 不起作用

发布于 2024-11-06 20:19:07 字数 779 浏览 1 评论 0原文

你好 我知道这个问题以前曾被问过,但那里的答案对我不起作用。

当重定向回我的网站时,我仍然得到了。

/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻的心爱 2024-11-13 20:19:08

我可以通过在 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 that current_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文