I spent some time searching for a way to not need the App ID and Secret Key for OmniAuth in an initializer. Luckily I ran across a post mentioning this link:
https://github.com/intridea/omniauth/wiki/Setup-Phase
By following these instructions, you can wait and set the App ID and Secret key at request time. In my case, I’m going to pull it out of a database table which stores config items.
My Current Code looks like this:
unless Rails.env.nil? CONFIG = YAML.load_file(Rails.root.join("config/secrets.yml"))[Rails.env] Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, CONFIG['fb_app_id'], CONFIG['fb_secret_key'], :scope => 'email,user_about_me,user_activities,user_birthday,user_groups', :display => 'popup' end end
And the future code will look like this:
SETUP_PROC = lambda do |env| config = Config.find(:first) env['omniauth.strategy'].options[:consumer_key] = config.facebook_key env['omniauth.strategy'].options[:consumer_secret] = config.facebook_secret end use OmniAuth::Builder.new do provider :facebook, :setup => SETUP_PROC end