Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

monkeypatch faraday_middleware oauth to work with put requests

  • Loading branch information...
commit 162a1c065d34cc8c6d43a96b98c928826dedad58 1 parent ecc8326
@adamkittelson adamkittelson authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 lib/faraday/request/oauth.rb
View
23 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
Please sign in to comment.
Something went wrong with that request. Please try again.