def _get_auth_response_with_retries(response_generator, num_of_retries=NUM_OF_RETRIES_FOR_AUTHENTICATION, auth_wait_time_sec=WAIT_TIME_FOR_AUTHENTICATION_RETRIES_SEC):
    '\n    Sends an authentication request (first time/refresh) with a retry mechanism.\n    :param response_generator (lambda)\n            A function call that sends the wanted REST request.\n    :return: The response received from the authentication server.\n    '
    for i in range((num_of_retries + 1)):
        try:
            response = response_generator()
            response.json()
            get_logger().info(f'Got an authentication response after {i} retries.')
            break
        except Exception:
            if (i == num_of_retries):
                response = _create_a_bad_response((('{"errors": ["Could not connect to authentication server", "Number of retries: ' + str(i)) + '"]}'))
            else:
                time.sleep(auth_wait_time_sec)
    return response
Sends an authentication request (first time/refresh) with a retry mechanism.
:param response_generator (lambda)
        A function call that sends the wanted REST request.
:return: The response received from the authentication server.
def _get_auth_response_with_retries(response_generator, num_of_retries=NUM_OF_RETRIES_FOR_AUTHENTICATION, auth_wait_time_sec=WAIT_TIME_FOR_AUTHENTICATION_RETRIES_SEC):
    '\n    Sends an authentication request (first time/refresh) with a retry mechanism.\n    :param response_generator (lambda)\n            A function call that sends the wanted REST request.\n    :return: The response received from the authentication server.\n    '
    for i in range((num_of_retries + 1)):
        try:
            response = response_generator()
            response.json()
            get_logger().info(f'Got an authentication response after {i} retries.')
            break
        except Exception:
            if (i == num_of_retries):
                response = _create_a_bad_response((('{"errors": ["Could not connect to authentication server", "Number of retries: ' + str(i)) + '"]}'))
            else:
                time.sleep(auth_wait_time_sec)
    return response