Class: Vhx::Middleware::OAuth2
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Vhx::Middleware::OAuth2
- Defined in:
- lib/vhx/middleware/oauth2.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ OAuth2
constructor
A new instance of OAuth2.
Constructor Details
#initialize(app, options = {}) ⇒ OAuth2
Returns a new instance of OAuth2.
16 17 18 19 |
# File 'lib/vhx/middleware/oauth2.rb', line 16 def initialize(app, ={}) super(app) @vhx_client = [:vhx_client] end |
Instance Method Details
#call(env) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vhx/middleware/oauth2.rb', line 4 def call(env) orig_env = env.dup begin @app.call(env) rescue InvalidTokenError @vhx_client.refresh_access_token! orig_env[:request_headers].merge!(@vhx_client.configured_headers) @app.call(orig_env) end end |