def unauthenticated_response(errors)
      # default to a blank realm, I suppose
      realm = @options[:realm] || ''
      response_headers = {"WWW-Authenticate" => %Q(OAuth realm="#{realm}"), 'Content-Type' => 'application/json'}

      body = {'errors' => errors}
      error_message = begin
        error_values = errors.values.inject([], &:+)
        if error_values.size <= 1
          error_values.first
        else
          # sentencify with periods 
          error_values.map { |v| v =~ /\.\s*\z/ ? v : v + '.' }.join(' ')
        end
      end
      body['error_message'] = error_message if error_message

      [401, response_headers, [JSON.pretty_generate(body)]]
    end
def unauthenticated_response(errors)
      # default to a blank realm, I suppose
      realm = @options[:realm] || ''
      response_headers = {"WWW-Authenticate" => %Q(OAuth realm="#{realm}"), 'Content-Type' => 'application/json'}

      body = {'errors' => errors}
      error_message = begin
        error_values = errors.values.inject([], &:+)
        if error_values.size <= 1
          error_values.first
        else
          # sentencify with periods 
          error_values.map { |v| v =~ /\.\s*\z/ ? v : v + '.' }.join(' ')
        end
      end
      body['error_message'] = error_message if error_message

      [401, response_headers, [JSON.pretty_generate(body)]]
    end
the response for an unauthenticated request. the argument will be a hash with the key 'errors', whose
 value is a hash with string keys indicating attributes with errors, and values being arrays of strings
 indicating error messages on the attribute key.