class Restforce::Middleware::Authentication

def authenticate!

Internal: Performs the authentication and returns the response body.
def authenticate!
  response = connection.post '/services/oauth2/token' do |req|
    req.body = encode_www_form(params)
  end
  raise Restforce::AuthenticationError, error_message(response) if response.status != 200
  @options[:instance_url] = response.body['instance_url']
  @options[:oauth_token]  = response.body['access_token']
  @options[:authentication_callback].call(response.body) if @options[:authentication_callback]
  response.body
end