docstr: If authentication feature is configured checks provided
  credentials.
  
  Parameters
  ----------
  api_version : str
      API version for authentication.
  
  Returns
  -------
  String
      None if authentication is not required and username and password are None.
      None if authentication is required and valid credentials provided.
      NotAuthorized if authenication is required and credentials are incorrect.
      NotRequired if authentication is not required but credentials are provided.
docstr_tok: ["If","authentication","feature","is","configured","checks","provided","credentials",".","Parameters","--","--","--","--","--","api_version",":","str","API","version","for","authentication",".","Returns","--","--","--","-","String","None","if","authentication","is","not","required","and","username","and","password","are","None",".","None","if","authentication","is","required","and","valid","credentials","provided",".","NotAuthorized","if","authenication","is","required","and","credentials","are","incorrect",".","NotRequired","if","authentication","is","not","required","but","credentials","are","provided","."]
code: def handle_authentication(self, api_version):
      """
      If authentication feature is configured checks provided
      credentials.
  
      Parameters
      ----------
      api_version : str
          API version for authentication.
  
      Returns
      -------
      String
          None if authentication is not required and username and password are None.
          None if authentication is required and valid credentials provided.
          NotAuthorized if authenication is required and credentials are incorrect.
          NotRequired if authentication is not required but credentials are provided.
      """
      self.logger.log(logging.DEBUG, "Handling authentication")
      found, method = self._get_auth_method(api_version)
      if not found:
          return AuthErrorStates.NotAuthorized
  
      if method == "":
          if not self._get_basic_auth_credentials():
              self.logger.log(
                  logging.DEBUG,
                  "authentication not required, username and password are none",
              )
              return AuthErrorStates.NONE
          else:
              self.logger.log(
                  logging.DEBUG,
                  "authentication not required, username and password are not none",
              )
              return AuthErrorStates.NotRequired
  
      if not self._get_credentials(method):
          return AuthErrorStates.NotAuthorized
  
      if not self._validate_credentials(method):
          return AuthErrorStates.NotAuthorized
  
      return AuthErrorStates.NONE
  
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 10 for calling the BaseHandler obj's underlying member method code with example usage: obj.handle_authentication(api_version) and returns: AuthErrorStates, AuthErrorStates, AuthErrorStates, AuthErrorStates, AuthErrorStates, AuthErrorStates