require 'sinatra' require "sinatra/reloader" require 'yaml' # configure sinatra set :run, false set :raise_errors, true # REQUEST STEP (server-side flow) get '/server-side' do # NOTE: You would just hit this endpoint directly from the browser in a real app. The redirect is # just here to explicit declare this server-side flow. redirect '/auth/facebook' end # REQUEST STEP (client-side flow) get '/client-side' do content_type 'text/html' # NOTE: When you enable cookie below in the FB.init call the GET request in the FB.login callback # will send a signed request in a cookie back the OmniAuth callback which will parse out the # authorization code and obtain an access_token with it. <<-HTML Client-side Flow Example

Connect to FB!

HTML end # CALLBACK STEP # - redirected here for server-side flow # - ajax request made here for client-side flow get '/auth/:provider/callback' do content_type 'application/json' MultiJson.encode(request.env) end