Koala :: Facebook :: AuthenticationError,验证访问令牌时出错

时间:2016-09-19 11:20:20

标签: ruby-on-rails facebook-graph-api heroku omniauth koala

我正在使用' omniauth-facebook'用facebook登录。 我能够在本地成功登录facebook。但部署到heroku后失败了。

我收到以下错误:

 Koala::Facebook::AuthenticationError (type: OAuthException, code: 190, error_subcode: 467, message: Error validating access token: This may be because the user logged out or may be due to a system error., x-fb-trace-id: GlM51Vo5azj [HTTP 400]):
2016-09-19T10:55:12.265269+00:00 app[web.1]:   app/controllers/home_controller.rb:8:in `result

omniauth.rb

OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'XXXXXXXXX', 'XXXXXXXXXXXXXXXXXXXXXX',
scope: 'publish_actions,email', :provider_ignores_state => true
end

我将用户数据存储在db

user.rb

 def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_initialize do |user|
  user.provider = auth.provider
  user.uid = auth.uid
  user.name = auth.info.name
  user.oauth_token = auth.credentials.token
  user.oauth_expires_at = Time.at(auth.credentials.expires_at)
  user.save!
end

sessions_controller

  def create
    user = User.from_omniauth(env["omniauth.auth"])
    session[:user_id] = user.id
    redirect_to result_home_path(user.id)
  end

当用户登录时,用户数据似乎没有正确更新。帮助我遇到类似问题的任何人。

0 个答案:

没有答案