Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created October 8, 2011 10:58
Show Gist options
  • Save josevalim/1272143 to your computer and use it in GitHub Desktop.
Save josevalim/1272143 to your computer and use it in GitHub Desktop.
Dynamic omniauth
class OmniauthController < ApplicationController
def start
request_phase(:facebook, client_id, client_secret)
end
def callback
callback_phase(:facebook, client_id, client_secret) do
render :text => "Done!"
end
end
def request_phase(name, *args, &block)
strategy = ::OmniAuth::Strategies.const_get(::OmniAuth::Utils.camelize(name.to_s))
block ||= lambda { |env| [404, { "Content-Type" => "text/plain" }, []] }
strategy.new(block, name, *args).call(env)
end
def callback_phase(name, *args, &block)
strategy = ::OmniAuth::Strategies.const_get(::OmniAuth::Utils.camelize(name.to_s))
strategy.new(block, name, *args).call(env)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment