0

我是一个大问题,我按照以下说明进行操作:

https://github.com/plataformatec/devise/wiki/OmniAuth:-概述

为了在我的应用程序中实现 Devise Facebook Omniauth,我将其放入

devise.rb(我使用 MAC OSX)

  require "omniauth-facebook"
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if Rails.env.development?
  config.omniauth :facebook, "501422263262172", "75b6641e4af169e385749060df0963a4"

这在模型中

用户.rb

  def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
    user = User.where(:provider => auth.provider, :uid => auth.uid).first
    unless user
      user = User.create(:name => auth.extra.raw_info.name,
                         :provider => auth.provider,
                         :uid => auth.uid,
                         :email => auth.info.email,
                         :password => Devise.friendly_token[0,20]
      )
    end
    user
  end


  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable,
         :validatable,:omniauthable, :omniauth_providers => [:facebook]

这在

用户/ominiauth_callbacks_controller.rb

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController


  def facebook
    # You need to implement the method below in your model (e.g. app/models/user.rb)
    @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

    if @user.persisted?
      sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
      set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end


end

这在

路线.rb

  devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

但是当我点击链接登录时,Facebook 会出现:

未找到。身份验证通道。

请帮助我,我不知道出了什么问题,我重新制作了这个过程并出现了同样的错误,如果有人怀疑我在这里回答的代码,非常感谢。

4

1 回答 1

0

Solve this upgrading from Rails 3.2 and Ruby 1.9.3 to Rails 4.0 and Ruby 2.0.0.

于 2013-08-11T03:12:38.573 回答