大家。 我在我的平台上使用简单的Facebook身份验证系统(使用Rails和Koala),它几乎按预期工作。但是有一个关键的错误让我疯狂。
client.get_access_token(params[:code])
OAuthException: Code was invalid or expired. Session is invalid. This could be because the application was uninstalled after the session was created.
步骤失败
醇>
简而言之,Facebook正在抱怨它刚刚提供的代码。以下是身份验证的方法:
OAuth的登录操作
def login
reset_session
session[:facebook_client] = get_client
redirect_to session[:facebook_client].url_for_oauth_code(:callback => FacebookAPI.oauth_callback_url, :permissions => "email, user_status, publish_stream, publish_actions")
rescue => err
end
回调行动
def terminate
client = session[:facebook_client]
if client.nil?
redirect_to '/', notice: 'Error on FacebookAPI'
else
access_token = client.get_access_token(params[:code]) if params[:code] # IT FAILS HERE
# omitting the rest
end