Class: Notion::Middleware::Authentication
- Inherits:
-
Object
- Object
- Notion::Middleware::Authentication
- Defined in:
- lib/notion/middleware/authentication.rb
Instance Method Summary collapse
- #call(request) ⇒ Object
-
#initialize(app, config) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(app, config) ⇒ Authentication
Returns a new instance of Authentication.
6 7 8 9 10 |
# File 'lib/notion/middleware/authentication.rb', line 6 def initialize(app, config) @app = app @config = config @refresh_mutex = Mutex.new end |
Instance Method Details
#call(request) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/notion/middleware/authentication.rb', line 12 def call(request) token = access_token raise ConfigurationError, "token is required" if token.nil? || token.empty? headers = request.headers.merge( "authorization" => "Bearer #{token}", "user-agent" => @config.user_agent ) @app.call(request.with(headers: headers)) end |