code: def _authenticate_client(self, client):
          
          if self.login and not self.restart_required:
              try:
                  db = client[self.auth_source]
                  if self.x509_extra_user:
                      db.authenticate(
                          DEFAULT_SUBJECT,
                          mechanism='MONGODB-X509'
                      )
                  else:
                      db.authenticate(
                          self.login, self.password)
              except Exception:
                  logger.exception(
                      "Could not authenticate to %r as %s/%s"
                      % (client, self.login, self.password))
                  raise
docs: Authenticate the client if necessary.