Class: Gapic::Rest::FaradayMiddleware::GoogleAuthorization
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Gapic::Rest::FaradayMiddleware::GoogleAuthorization
- Defined in:
- lib/gapic/rest/faraday_middleware.rb
Overview
Request middleware that constructs the Authorization HTTP header using ::Google::Auth::Credentials
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, credentials) ⇒ GoogleAuthorization
constructor
A new instance of GoogleAuthorization.
Constructor Details
#initialize(app, credentials) ⇒ GoogleAuthorization
Returns a new instance of GoogleAuthorization.
28 29 30 31 |
# File 'lib/gapic/rest/faraday_middleware.rb', line 28 def initialize app, credentials @credentials = credentials super app end |
Instance Method Details
#call(env) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/gapic/rest/faraday_middleware.rb', line 34 def call env auth_hash = @credentials.client.apply({}) env.request_headers["Authorization"] = auth_hash[:authorization] @app.call env end |