Class: FaradayMiddleware::YoutubeOAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::YoutubeOAuth
- Defined in:
- lib/tubeclip/middleware/faraday_oauth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ YoutubeOAuth
constructor
A new instance of YoutubeOAuth.
Constructor Details
#initialize(app, options) ⇒ YoutubeOAuth
Returns a new instance of YoutubeOAuth.
17 18 19 |
# File 'lib/tubeclip/middleware/faraday_oauth.rb', line 17 def initialize(app, ) @app, @options = app, end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tubeclip/middleware/faraday_oauth.rb', line 5 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 |