0

嗨,我知道以前有人问过这个问题,但那里的答案对我不起作用。

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

/auth/failure?message=invalid_response

我安装了 ruby​​ 1.9.2p180(2011-02-18 修订版 30909)[x86_64-darwin10.6.0],使用 rails 3.0.7 并安装了所需的 gem。我在另一个线程上读到,您应该将 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
4

1 回答 1

1

我可以通过在我的 Gemfile 中指定以下内容来使其工作

gem 'omniauth', '0.2.0'

0.2.6 版对我不起作用。我也由 .rvmrc 更新为rvm use 1.9.2@rails3. 哦,还要确保您已登录 - 请注意,在您上面的代码中,您假设current_user存在。有关允许通过 Omniauth 创建用户的信息,请参阅 Ryan 的Railscast 第二部分。

我在这里有一个演示,但请注意我是从头开始进行身份验证,而不是使用设计。

于 2011-06-20T08:55:37.760 回答