We're trying to use the linkedin-omniauth gem in a Rails application that's behind an http proxy.
I've tried everything I can find to get omniauth to use the proxy but I cannot get it to work.
The following post suggests using:
provider :linkedin, 'xxx', 'xxx', {
:client_options => {
:proxy => ENV["HTTP_PROXY"] || ENV["http_proxy"]
}
}
Which doesn't work for me and I see no mention of 'proxy' in the source. I've also tried hard coding the proxy. No success.
This SO post doesn't work for me either.
I also created an initialiser for net::http with a proxy. That also doesn't work. I've exported the proxy in my shell and bashrc. And in /etc/environment. Nothing's working.
How can I get omniauth to use an outbound proxy?
--- UPDATE ---
Whilst the accepted answer below does indeed work for Linkedin Oauth, most gems now rely on Oauth2. This does away with Net::HTTP and introduces Faraday which has a separate set on rules for the proxy / connection settings:
https://github.com/simonmorley/oauth2/blob/master/lib/oauth2/client.rb#L36
In order to get a proxy working with later gems (inc. popular Facebook, Google, Github check what gem they rely on), you need to use the following in your initialiser:
provider :foursquare, 'xxx', 'xxx', {
:client_options => {
:connection_opts => {
:proxy => "http://127.0.0.1:3128"
}
}
}