Class: CognitiveFaculty::AccessTokenMiddleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/cognitive_faculty.rb

Overview

Faraday middleware for adding the OIDC access token at each request. If the access token is expired, a new token will be requested.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



48
49
50
51
52
# File 'lib/cognitive_faculty.rb', line 48

def call(env)
  token = CognitiveFaculty.configuration.auth.access_token
  env[:request_headers]["Authorization"] = "Bearer #{token}"
  @app.call(env)
end