Skip to content

Instantly share code, notes, and snippets.

@andreaseger
Created March 6, 2011 00:27
Show Gist options
  • Save andreaseger/856872 to your computer and use it in GitHub Desktop.
Save andreaseger/856872 to your computer and use it in GitHub Desktop.
require 'sinatra/base'
require 'omniauth'
class OmniauthExample < Sinatra::Base
configure do
use OmniAuth::Builder do
provider :facebook, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, { :scope => 'email, publish_stream' }
provider :twitter, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET
end
enable :sessions
end
def clear_session
session[:user_key] = nil
session[:fb_token] = nil
session[:fb_error] = nil
end
get '/auth/:name/callback' do
auth = request.env['omniauth.auth']
# do something
redirect_to request.env['omniauth.origin'] || '/'
end
get '/auth/failure' do
clear_session
redirect_to '/'
end
get '/signout' do
clear_session
redirect '/'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment