ruby on rails - New User gets a blank page by entering from Facebook canvas -
every time when new user (or test user) access app facebook (canvas) gets empty page.
if user navigate direct app works. user permission dialog facebook , have grant requested permissions. after user can use app facebook canvas or direct *www.my_app.com*.
what know problem:
- it occurs new/test user did not grant permissions facebook app
- it occurs on direct access facebook canvas.
i think permission dialog can't shown facebook don't know why.
my app developed ruby rails , uses omniauth 1.4.0 login.
the gem-file
gem 'omniauth' gem 'omniauth-facebook', '1.4.0' gem 'oauth2' gem 'koala'
the routes.rb:
match '/canvas' => 'sessions#facebook_canvas' match '/auth/:provider/callback' => 'sessions#create', :as => :create_session
the omniauth.rb initializer:
rails.application.config.middleware.use omniauth::builder openssl::ssl::verify_peer = openssl::ssl::verify_none provider :facebook, app_id, app_secret, {:scope => 'email, user_groups, friends_groups, read_stream, read_friendlists, friends_likes, friends_status, offline_access', :display => 'popup', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}} } end
the sessions_controller :
# modified sample code omniauth handle signed request def facebook_canvas session[:canvas] = true session[:signed_request] = params[:signed_request] # redirect /auth/facebook here parse # signed_request fb sends us, asking auth if user has # not granted access, or moving straight # callback have granted access. # # pass state parameter can detect in our callback # custom rendering/redirection canvas app page redirect_to "/auth/facebook?signed_request=#{request.params['signed_request']}&state=canvas" end # create session, when user def create auth = request.env["omniauth.auth"] user = user.from_omniauth(env["omniauth.auth"]) if user session[:fb_token] = auth["credentials"]["token"] if auth['provider'] == 'facebook' redirect_to_target_or_default root_url #, :notice => "logged in successfully." redirect_to confirm_abg_path(:user => user.id) else flash.now[:alert] = "invalid login or password." redirect_to root_url end end
i hope can me.
Comments
Post a Comment