Sha256: 8295b31530a5e2e1dcd48dfd58384383bd4205c65d2ae670f0f2e81e5802bb76

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

require 'faraday'

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

    def call(env)
      params = env[:body].is_a?(Hash) ? env[:body] : {}

      signature_params = params.reject{ |k,v| v.respond_to?(:content_type) }

      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

1 entries across 1 versions & 1 rubygems

Version Path
faraday_middleware-0.6.0 lib/faraday/request/oauth.rb