Class: Podio::Middleware::OAuth2
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Podio::Middleware::OAuth2
- Defined in:
- lib/podio/middleware/oauth2.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ OAuth2
constructor
A new instance of OAuth2.
Constructor Details
#initialize(app) ⇒ OAuth2
Returns a new instance of OAuth2.
23 24 25 |
# File 'lib/podio/middleware/oauth2.rb', line 23 def initialize(app) super end |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/podio/middleware/oauth2.rb', line 6 def call(env) podio_client = env[:request][:client] orig_env = env.dup begin @app.call(env) rescue TokenExpired podio_client.refresh_access_token # new access token needs to be put into the header orig_env[:request_headers].merge!(podio_client.configured_headers) # redo the request with the new access token @app.call(orig_env) end end |