im a big problem i follow the instructions in :
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
To implement Devise Facebook Omniauth in my app, i put this in
devise.rb (i use MAC OSX)
require "omniauth-facebook"
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if Rails.env.development?
config.omniauth :facebook, "501422263262172", "75b6641e4af169e385749060df0963a4"
this in model
user.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]
and this in
users/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
and this in
routes.rb
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
But when i click in link to login whit Facebook appear this:
Not found. Authentication passthru.
Please help me i dont know what is wrong i remake the process and appear same error, thanks much if someone doubt about the code I am here to answer.
解决了从Rails 3.2和Ruby 1.9.3到Rails 4.0和Ruby 2.0.0的升级。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.