Class: The86::Client::OauthBearerAuthorization
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- The86::Client::OauthBearerAuthorization
- Defined in:
- lib/the86-client/oauth_bearer_authorization.rb
Overview
A Faraday middleware which adds or overwrites the Authorization header with an OAuth2 bearer token. See: tools.ietf.org/html/draft-ietf-oauth-v2-bearer-22
Constant Summary collapse
- AUTH_HEADER =
"Authorization"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, token) ⇒ OauthBearerAuthorization
constructor
A new instance of OauthBearerAuthorization.
Constructor Details
#initialize(app, token) ⇒ OauthBearerAuthorization
Returns a new instance of OauthBearerAuthorization.
10 11 12 13 |
# File 'lib/the86-client/oauth_bearer_authorization.rb', line 10 def initialize(app, token) super(app) @token = token end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 |
# File 'lib/the86-client/oauth_bearer_authorization.rb', line 15 def call(env) env[:request_headers][AUTH_HEADER] = "Bearer #{@token}" @app.call(env) end |