Class: Restforce::Middleware::Authorization

Inherits:
Restforce::Middleware show all
Defined in:
lib/restforce/middleware/authorization.rb

Overview

Piece of middleware that simply injects the OAuth token into the request headers.

Constant Summary collapse

AUTH_HEADER =
'Authorization'.freeze

Instance Method Summary collapse

Methods inherited from Restforce::Middleware

#client, #connection, #initialize

Constructor Details

This class inherits a constructor from Restforce::Middleware

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
# File 'lib/restforce/middleware/authorization.rb', line 8

def call(env)
  env[:request_headers][AUTH_HEADER] = %(OAuth #{token})
  @app.call(env)
end

#tokenObject



13
14
15
# File 'lib/restforce/middleware/authorization.rb', line 13

def token
  @options[:oauth_token]
end