Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Faraday 0.8 is compatible with current usage, so why not allowing to use it? #34

merged 4 commits into from

5 participants

Saverio Trioni Nathan Manousos Ryan Biesemeyer Luke Gruber Shayne Sweeney
Saverio Trioni

The only relevant change is in the signature of Connection#get et al. when headers are in the arguments (second arg in 0.7, third arg in 0.8). The block form Connection.get { |req| .... } has the same usage in both versions, and this is the form used in the code.

Nathan Manousos

You don't get undefined method `query_values' for #<URI::HTTPS:0x007ff5f24b1618> errors when using Faraday 0.8?

Saverio Trioni

Whoa, that was a huge mistest, I didn't enforce 0.8 version when running the tests. Now the source of the missing method (dropping automatic usage of Addressable::URI) is solved by converting the uri into an addressable one.

I have a lot of missing stubs now. As soon as they are fixed (so both with 0.7.6 and 0.8.0), i'll push again and ping you...

Saverio Trioni


Nathan Manousos

Works for me! +1

Saverio Trioni

Hey, ma2gedev's commit is much better in my opinion (for what concerns the oauth middleware, as it is not forcing the use of Addressable, using only Faraday helpers. I'll add (sort of) his implementation over here, then you choose what to integrate.

Saverio Trioni

I removed the need of Addressable::URI, using the Faraday::Utils methods, but unlike in ma2gedev's commit, the query is correctly reset to nil when empty (so tests pass) and there is less changed code.

Saverio Trioni

By the way, all this would be totally useless if Instagram supported having OAuth2 data in headers only (I'm sure the specification don't require both!) so we could use a much simpler auth middleware like the one provided in next faraday_middleware release (builder.use :auth, "Token", :token => access_token)

Ryan Biesemeyer yaauie referenced this pull request from a commit in simplymeasured/instagram-ruby-gem
Ryan Biesemeyer yaauie merge pull #34 from @rewritten to handle Faraday >= 0.8 d962295
Ryan Biesemeyer

+1 on getting this merged into master. I just merged it into our shallow-fork.

Luke Gruber

+1 to merge into master please.

Shayne Sweeney shayne merged commit 3bab309 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +1 −1  instagram.gemspec
  2. +6 −6 lib/faraday/oauth2.rb
2  instagram.gemspec
@@ -5,7 +5,7 @@ do |s|
s.add_development_dependency('rspec', '~> 2.4')
s.add_development_dependency('webmock', '~> 1.6')
s.add_development_dependency('bluecloth', '~> 2.0.11')
- s.add_runtime_dependency('faraday', '~> 0.7')
+ s.add_runtime_dependency('faraday', ['>= 0.7', '< 0.9'])
s.add_runtime_dependency('faraday_middleware', '~> 0.8')
s.add_runtime_dependency('multi_json', '~> 1.0.3')
s.add_runtime_dependency('hashie', '>= 0.4.0')
12 lib/faraday/oauth2.rb
@@ -5,16 +5,16 @@ module FaradayMiddleware
# @private
class OAuth2 < Faraday::Middleware
def call(env)
if env[:method] == :get or env[:method] == :delete
- env[:url].query_values = {} if env[:url].query_values.nil?
+ query = Faraday::Utils.parse_query(env[:url].query)
- if @access_token and not env[:url].query_values["client_secret"]
- env[:url].query_values = env[:url].query_values.merge(:access_token => @access_token)
+ if @access_token and not query["client_secret"]
+ query.update(:access_token => @access_token)
env[:request_headers] = env[:request_headers].merge('Authorization' => "Token token=\"#{@access_token}\"")
elsif @client_id
- env[:url].query_values = env[:url].query_values.merge(:client_id => @client_id)
+ query.update(:client_id => @client_id)
+ env[:url].query = Faraday::Utils.build_query(query)
if @access_token and not env[:body] && env[:body][:client_secret]
env[:body] = {} if env[:body].nil?
@@ -25,7 +25,7 @@ def call(env)
- env[:url].query_values = nil if env[:url].query_values == {}
+ env[:url].query = nil if env[:url].query == "" env
Something went wrong with that request. Please try again.