Sha256: 281bffccac13cebd7ea22a06a14c1689dd204cf54aafe1e9cf4a878bdfd508b4

Contents?: true

Size: 677 Bytes

Versions: 29

Compression:

Stored size: 677 Bytes

Contents

# Borrowed from https://github.com/pengwynn/faraday_middleware/blob/master/lib/faraday/request/oauth.rb
class ApiClient::Connection::Middlewares::Request::OAuth < Faraday::Middleware

  dependency 'simple_oauth'

  def call(env)
    params = 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
    env[:request_headers]['User-Agent'] = "ApiClient gem v#{ApiClient::VERSION}"

    @app.call(env)
  end

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

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
api_client-0.1.8 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.7 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.6 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.5 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.4 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.3 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.2 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.1 lib/api_client/connection/middlewares/request/oauth.rb
api_client-0.1.0 lib/api_client/connection/middlewares/request/oauth.rb