import requests


def get_auth(url: str, login: str, password: str) -> tuple:
    """
    Function get authentication token and user ID from Rocket.Chat.

    :param url: Rocket.Chat API login URL
    :type: str
    :param login: Rocket.Chat user login
    :type: str
    :param password: Rocket.Chat user password
    :type: str
    :return: tuple with userID and authToken
    :rtype: tuple
    """

    try:
        headers = {'Content-Type': 'application/json'}
        timeout = (1, 3)
        resp = requests.post(url, headers=headers, json={'username': login, 'password': password}, timeout=timeout)

        resp_json = resp.json()

        if resp_json['status'] == 'success':
            return resp_json['data']['userId'], resp_json['data']['authToken']
        else:
            return resp_json['status'], resp_json['error']
    except requests.exceptions.SSLError:
        raise SystemExit('ERROR: Cannot verify SSL Certificate.')
    except requests.exceptions.ConnectTimeout:
        raise SystemExit('ERROR: Cannot connect to Rocket.Chat API - connection timeout')
    except requests.exceptions.ConnectionError as e:
        raise SystemExit("ERROR: Cannot connect to Rocket.Chat API {}.".format(e))