diff --git a/.gitignore b/.gitignore index 275f0fe..ae44b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ pkg/* .powenv tmp bin -example/app.log diff --git a/example/app.rb b/example/app.rb index a078746..142da58 100644 --- a/example/app.rb +++ b/example/app.rb @@ -6,88 +6,79 @@ require 'yaml' set :run, false set :raise_errors, true -# setup logging to file -log = File.new("app.log", "a+") -$stdout.reopen(log) -$stderr.reopen(log) -$stderr.sync = true -$stdout.sync = true - -# server-side flow +# 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. + # 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 -# client-side flow +# 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. - <<-END + # 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!

+ + - END + 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 - -get '/auth/failure' do - content_type 'application/json' - MultiJson.encode(request.env) -end diff --git a/example/config.ru b/example/config.ru index 17f0760..a716c87 100644 --- a/example/config.ru +++ b/example/config.ru @@ -5,7 +5,7 @@ require './app.rb' use Rack::Session::Cookie, :secret => 'abc123' use OmniAuth::Builder do - provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], :scope => 'email,read_stream' + provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'] end run Sinatra::Application