Skip to content

Commit

Permalink
monkeypatch faraday_middleware oauth to work with put requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Kittelson committed Jul 15, 2011
1 parent ecc8326 commit 162a1c0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/faraday/request/oauth.rb
@@ -0,0 +1,23 @@
require 'faraday'

module Faraday
class Request::OAuth < Faraday::Middleware
dependency 'simple_oauth'

def call(env)
params = env[:body] || {}

signature_params = params.reject{ |k,v| v.respond_to?(:content_type) || (env[:method] == :put) }

header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)

env[:request_headers]['Authorization'] = header.to_s

@app.call(env)
end

def initialize(app, options)
@app, @options = app, options
end
end
end

0 comments on commit 162a1c0

Please sign in to comment.