Class: BookingSync::API::Middleware::Authentication
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- BookingSync::API::Middleware::Authentication
- Defined in:
- lib/bookingsync/api/middleware/authentication.rb
Overview
Provides faraday middleware for authentication using OAuth token We don’t use default FaradayMiddleware::OAuth2 because it adds access_token param to the URL
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, token) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(app, token) ⇒ Authentication
Returns a new instance of Authentication.
6 7 8 9 |
# File 'lib/bookingsync/api/middleware/authentication.rb', line 6 def initialize(app, token) @app = app @token = token end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 |
# File 'lib/bookingsync/api/middleware/authentication.rb', line 11 def call(env) env[:request_headers]["Authorization"] = "Bearer #{@token}" @app.call(env) end |