Class: Flattr::Request::FlattrOAuth2
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Flattr::Request::FlattrOAuth2
- Defined in:
- lib/flattr/request/oauth2.rb
Instance Method Summary collapse
- #authorization_header ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ FlattrOAuth2
constructor
A new instance of FlattrOAuth2.
Constructor Details
#initialize(app, options) ⇒ FlattrOAuth2
Returns a new instance of FlattrOAuth2.
12 13 14 |
# File 'lib/flattr/request/oauth2.rb', line 12 def initialize(app, ) @app, @options = app, end |
Instance Method Details
#authorization_header ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/flattr/request/oauth2.rb', line 16 def if @options[:access_token] "Bearer #{@options[:access_token]}" elsif @options[:client_id] && @options[:client_secret] "Basic #{Flattr::Client.base64_encode("#{@options[:client_id]}:#{@options[:client_secret]}")}" else nil end end |
#call(env) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/flattr/request/oauth2.rb', line 5 def call(env) if env[:request_headers]['Authorization'] = end @app.call(env) end |