Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixed missing 'query_values' method with version 0.8 of Faraday. #35

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+9 −7
Split
View
@@ -5,7 +5,7 @@ Gem::Specification.new 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.8')
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')
View
@@ -7,13 +7,17 @@ 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?
+ if env[:url].query.nil?
+ query = {}
+ elsif
+ query = Faraday::Utils.parse_query(env[:url].query)
+ end
- 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"]
+ env[:url].query = Faraday::Utils.build_query(query.merge(: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)
+ env[:url].query = Faraday::Utils.build_query(query.merge(:client_id => @client_id))
end
else
if @access_token and not env[:body] && env[:body][:client_secret]
@@ -25,8 +29,6 @@ def call(env)
end
end
- env[:url].query_values = nil if env[:url].query_values == {}
-
@app.call env
end