Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook,       Rails.application.config.facebook_app_id,  Rails.application.config.facebook_app_secret,  {name: "facebook", :scope => 'email,user_location'}
  # add these back later if needed
  # userinfo.email, userinfo.profile, https://www.google.com/m8/feeds,
  provider :google_oauth2,  Rails.application.config.google_client_id, Rails.application.config.google_secret,        {name: "google_login", prompt: 'consent', scope: ['youtube', 'youtube.force-ssl', 'youtube.upload','userinfo.email','userinfo.profile']}
  provider :twitter,        Rails.application.config.twitter_app_id,   Rails.application.config.twitter_app_secret,   {x_auth_access_type: 'write' }
  provider :stripe_connect, Rails.application.config.stripe[:client_id], Rails.application.config.stripe[:secret_key],    {}
end

# https://github.com/intridea/omniauth/wiki/FAQ
OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}