OmniAuth Facebook expired token error

前端 未结 3 885
滥情空心
滥情空心 2021-02-04 22:14

I am using OmniAuth to get access to Facebook in my app. I am using the fb_graph gem: https://github.com/nov/fb_graph to post to Facebook. I am running omniauth-0.3.0 on Heroku

3条回答
  •  情书的邮戳
    2021-02-04 22:47

    You can simply update the token when you create the session.

    class SessionsController < ApplicationController  
    def create  
      auth = request.env["omniauth.auth"]  
      user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]).tap do |u|
               u.update_attributes(:token => auth["credentials"]["token"]) if u
             end || User.create_with_omniauth(auth)
      session[:user_id] = user.id  
      redirect_to root_url, :notice => "Signed in!"  
    end 
    

提交回复
热议问题