Class: Tumble::Request::TumblrOAuth

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/tumble/request/oauth.rb

Instance Method Summary (collapse)

Constructor Details

- (TumblrOAuth) initialize(app, options)

Returns a new instance of TumblrOAuth



16
17
18
19
# File 'lib/tumble/request/oauth.rb', line 16

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

Instance Method Details

- (Object) call(env)



8
9
10
11
12
13
14
# File 'lib/tumble/request/oauth.rb', line 8

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