Created
March 6, 2011 00:27
-
-
Save andreaseger/856872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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