This question was asked in another post at Facebook iframe app being redirected out of canvas after user authorization, however, I'm having the same problem and don't understand how to implement the fix described in the post. If they posted the fixed controller, it would be awesome. Here's my controller.
class AppController < ApplicationController
def index
@oauth = Koala::Facebook::OAuth.new("APP_ID", "APP_SECRET", "https://quiet-mist-8418.heroku.com/app/redirect" )
if (session[:access_token].blank?)
redirect_to @oauth.url_for_oauth_code and return
end
@graph = Koala::Facebook::API.new(session[:access_token])
@friends = @graph.get_connections("me", "friends").to_s
end
def redirect
@oauth = Koala::Facebook::OAuth.new("APP_ID", "APP_SECRET", "https://quiet-mist-8418.heroku.com/app/redirect" )
session[:access_token] = @oauth.get_access_token(params[:code]) if params[:code]
redirect_to(:action=>"index")
end
end
Interestingly, I went to the settings page of my the Facebook developer app, and made some changes to the settings > auth dialogue section, and it seems to be working as desired. I checked the section marked, "authentication referrals." Now, it stays on the page after authorizing.