class Restforce::Middleware::Authentication

the oauth access token (if a refresh token is present).
will attempt to either reauthenticate (username and password) or refresh
When a request fails (ie. A status of 401 is returned). The middleware
Faraday middleware that allows for on the fly authentication of requests.

def authenticate!

def authenticate!
  raise 'must subclass'
end

def call(env)

def call(env)
  begin
    return authenticate! if force_authenticate?(env)
    @app.call(env)
  rescue Restforce::UnauthorizedError
    authenticate!
    @app.call(env)
  end
end

def connection

def connection
  @connection ||= Faraday.new(:url => "https://#{@options[:host]}") do |builder|
    builder.response :json
    builder.response :logger, Restforce.configuration.logger if Restforce.log?
    builder.adapter Faraday.default_adapter
  end
end

def force_authenticate?(env)

def force_authenticate?(env)
  env[:request_headers] && env[:request_headers]['X-ForceAuthenticate']
end