Skip to content
This repository

Dynamic Providers

If you wish to dynamically set up a provider, the proper way as of 1.0 is to use the setup phase. The setup phase is a Rack endpoint that is called but not rendered to the user before both the request and callback phases of the OmniAuth lifecycle. For instance, if I wanted to dynamically set the :foo option on the strategy based on the session, I could do something like this:

use OmniAuth::Builder do
  provider :example, :setup => lambda{|env| env['omniauth.strategy'].options[:foo] = env['rack.session']['foo'] }
end

If you are looking to simply replace the default OmniAuth forms with something more friendly to your particular application, you will be able to simply pass a :form option with a Rack endpoint that will render in place of the OmniAuth default form. For example, in a Rails application you might do something like this:

use OmniAuth::Builder do
  provider :example, :form => SessionsController.action(:new)
end
Something went wrong with that request. Please try again.