Sha256: 5ac82b59aa5e642026956c563ad73be9c25830a1cf2a12c2b92e4bb9d7e1f356

Contents?: true

Size: 535 Bytes

Versions: 7

Compression:

Stored size: 535 Bytes

Contents

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
desk-0.3.3 lib/faraday/request/oauth.rb
desk-0.3.2 lib/faraday/request/oauth.rb
desk-0.3.1 lib/faraday/request/oauth.rb
desk-0.3.0 lib/faraday/request/oauth.rb
assistly-0.2.6 lib/faraday/request/oauth.rb
assistly-0.2.5 lib/faraday/request/oauth.rb
assistly-0.2.4 lib/faraday/request/oauth.rb