Facebook身份验证无法在Ruby on Rails中运行

时间:2013-06-02 14:20:59

标签: ruby-on-rails ruby-on-rails-3 facebook

在网站网址下的我的Facebook应用中,我放了 - http://www.mydomainname.com/users/auth/facebook/callback

我已将所有的facebook凭据正确放入config / initalizers / devise.rb

用户需要点击http://www.mydomain.com/profile上指向http://www.mydomainname.com/users/auth/facebook但未发生任何事情的图片,它看起来页面正在重定向,然后它只显示=“> http:// www .mydomain.com来/简档# =

我检查了我的production.log文件并显示(为了安全起见,我已删除部分令牌)

Started GET "/users/auth/facebook" for 108.107.140.124 at 2013-06-02 14:15:19 +0000


Started GET "/users/auth/facebook/callback?code=KJHKJHJKHKHJyadhanIUGYagdnianduifayuidfnyYYKghwViqVXpe6a69be8d50d51f9e971a06" for 108.107.140.124 at 2013-06-02 14:15:21 +0000
Processing by AuthenticationsController#facebook as HTML
  Parameters: {"code"=>"AQCJZPxjvAPbsHxcueSRKfK5xWQWlhxofFUBblb0fyyHgulTcPmZEVn5TzVhAbDBK1e4SPE21uIVTOj9nJ7r6lJMYYKghwViqVXpltdtEylL-v1V-EH9X9wUDLrVS3igX-al3L98MiYgW6YdPJhENBXRt3iksbmSXo33NHot8LMC8ntI9P8V0jybVXF9RZrfXetRoPrDzYsYt1mPfHB-y11evq_RKejvecHJFM81vH070uzBtS2kdjZcQNgwCdnd5CKKUHLyS22W1TAnY_m_BYjWYm59a1QfLyU2IFzeSUP0fjIp3RquzGFjAqBVpAo9MH8", "state"=>"87302acdf98eaf5ef54230526e6a69be8d50d51f9e971a06"}
**Redirected to http://www.mydomainname.com/profile**
Completed 302 Found in 11ms (ActiveRecord: 4.0ms)

一切看起来还不错,但是没有认证,我做错了什么?

编辑 - Authentication_controller.rb文件有

  def facebook
    omni = request.env["omniauth.auth"]
    token = omni['credentials'].token
    token_secret = omni['credentials'].secret

    authentication = Authentication.find_by_provider_and_uid(omni['provider'], omni['uid'])
    if authentication
      authentication.update_attributes(:token => token, :token_secret => token_secret)
    elsif current_user
      current_user.authentications.create!(:provider => omni['provider'], :uid => omni['uid'], :token => token, :token_secret => token_secret)
    end 

    flash[:notice] = "Successfully connected with facebook"
    redirect_to profiles_path
  end

0 个答案:

没有答案