Class: FaradayMiddleware::OAuth2 Private
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::OAuth2
- Defined in:
- lib/faraday/request/oauth2.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Simple middleware that adds the access token to each request.
The access token is placed in the “Authorization” HTTP request header. However, an explicit “Authorization” header for the current request will not be overriden.
Instance Method Summary collapse
- #call(env) ⇒ Object private
-
#initialize(app, token = nil) ⇒ OAuth2
constructor
private
A new instance of OAuth2.
Constructor Details
#initialize(app, token = nil) ⇒ OAuth2
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OAuth2.
20 21 22 23 |
# File 'lib/faraday/request/oauth2.rb', line 20 def initialize(app, token = nil) super(app) @token = token end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 |
# File 'lib/faraday/request/oauth2.rb', line 15 def call(env) env[:request_headers][AUTH_HEADER] ||= %(Bearer #{@token}) if @token @app.call env end |