class_docstr: Base class for the downloaders
class_docstr_tok: ["Base","class","for","the","downloaders"]
code: def _handle_authentication(
      self,
      url,
      needs_authentication,
      e,
      ce,
      access_denied,
      msg_types,
      supported_auth_types,
      used_old_session,
  ):
      if needs_authentication:
          # so we knew it needs authentication
          if not used_old_session:
              # we did use new cookies, we knew that authentication is needed
              # but still failed. So possible cases:
              #  1. authentication credentials changed/were revoked
              #     - allow user to re-enter credentials
              #  2. authentication mechanisms changed
              #     - we can't do anything here about that
              #  3. bug in out code which would render
              #  authentication/cookie handling
              #     ineffective
              #     - not sure what to do about it
              if not ui.is_interactive:
                  lgr.error(
                      "Interface is non interactive, so we are "
                      "reraising: %s",
                      ce,
                  )
                  raise e
              self._enter_credentials(
                  url,
                  denied_msg=access_denied,
                  auth_types=supported_auth_types,
                  new_provider=False,
              )
      else:  # None or False
          if needs_authentication is False:
              # those urls must or should NOT require authentication
              # but we got denied
              raise DownloadError(
                  "Failed to download from %s, which must be available"
                  "without authentication but access was denied. "
                  "Adjust your configuration for the provider.%s"
                  % (url, msg_types)
              )
          else:
              # how could be None or any other non-False bool(False)
              assert needs_authentication is None
              # So we didn't know if authentication necessary, and it
              # seems to be necessary, so Let's ask the user to setup
              # authentication mechanism for this website
              self._enter_credentials(
                  url,
                  denied_msg=access_denied,
                  auth_types=supported_auth_types,
                  new_provider=True,
              )
  
imports: import msgpack
  import os
  import sys
  import time
  from abc import ABCMeta, abstractmethod
  import os.path
  from os.path import exists, join, isdir
  from ..None import cfg
  from ..ui import ui
  from ..utils import auto_repr, ensure_unicode, unlink
  from .credentials import CompositeCredential
  from datalad.downloaders import CREDENTIAL_TYPES
  from ..support.exceptions import AccessDeniedError, AccessPermissionExpiredError, AnonymousAccessDeniedError, CapturedException, DownloadError, IncompleteDownloadError, UnaccountedDownloadError
  from ..support.locking import InterProcessLock, try_lock, try_lock_informatively
  from logging import getLogger
label_desc: Use image node_id 3 for calling the BaseDownloader obj's underlying member method code with example usage: obj._handle_authentication(url, needs_authentication, e, ce, access_denied, msg_types, supported_auth_types, used_old_session) without return types