小编Sha*_*rao的帖子

OmniAuth Facebook过期令牌错误

我正在使用OmniAuth在我的应用程序中访问Facebook.我正在使用fb_graph gem:https://github.com/nov/fb_graph发布到Facebook.我正在Heroku上为这个应用程序运行omniauth-0.3.0.创建用户时保存的令牌会在用户稍后登录时更改.

用于创建用户的代码

    class SessionsController < ApplicationController  
    def create  
     auth = request.env["omniauth.auth"]  
     user = User.find_by_provider_and_uid(auth["provider"], auth["uid"])||           
     User.create_with_omniauth(auth)
       session[:user_id] = user.id  
       redirect_to root_url, :notice => "Signed in!"  
         end 
Run Code Online (Sandbox Code Playgroud)

用户模型是:

  def self.create_with_omniauth(auth)  
    create! do |user|  
    user.provider = auth["provider"]  
    user.uid = auth["uid"]  
    user.name = auth["user_info"]["name"] 
    user.token = auth["credentials"]["token"]
    end
   end
Run Code Online (Sandbox Code Playgroud)

我现在在大约30%的用户身上看到这个错误 -

 FbGraph::InvalidToken (OAuthException :: Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the …
Run Code Online (Sandbox Code Playgroud)

ruby facebook rubygems ruby-on-rails omniauth

3
推荐指数
1
解决办法
5580
查看次数

标签 统计

facebook ×1

omniauth ×1

ruby ×1

ruby-on-rails ×1

rubygems ×1