docstr: Prepares server 401 response and server 406 response depending
  on the value of the self.auth_error flag
docstr_tok: ["Prepares","server","401","response","and","server","406","response","depending","on","the","value","of","the","self.auth_error","flag"]
code: def fail_with_auth_error(self):
      """
      Prepares server 401 response and server 406 response depending
      on the value of the self.auth_error flag
      """
      if self.auth_error == AuthErrorStates.NotAuthorized:
          self.logger.log(
              logging.ERROR, "Failing with 401 for unauthorized request"
          )
          self.set_status(401)
          self.set_header(
              "WWW-Authenticate",
              f'Basic realm="{self.tabpy_state.name}"',
          )
          self.error_out(
              401,
              info="Unauthorized request.",
              log_message="Invalid credentials provided.",
          )
      else:
          self.logger.log(
              logging.ERROR, "Failing with 406 for Not Acceptable"
          )
          self.set_status(406)
          self.set_header(
              "WWW-Authenticate",
              f'Basic realm="{self.tabpy_state.name}"',
          )
          self.error_out(
              406,
              info="Not Acceptable",
              log_message="Username or password provided when authentication not available.",
          )
  
imports: import base64
  import binascii
  import concurrent
  import json
  import logging
  import tornado.web
  from tabpy.tabpy_server.app.app_parameters import SettingsParameters
  from tabpy.tabpy_server.handlers.util import hash_password
  from tabpy.tabpy_server.handlers.util import AuthErrorStates
  import uuid
label_desc: Use image node_id 12 for calling the BaseHandler obj's underlying member method code with example usage: obj.fail_with_auth_error() without return types