def parse_token(token: str, coding='utf-8') -> Tuple[str, str]:
    """Get login + password tuple from Basic Auth token.
    """
    try:
        b_token = bytes(token, encoding=coding)
    except UnicodeEncodeError as e:
        raise BasicAuthException from e
    except TypeError as e:
        raise BasicAuthException from e

    try:
        auth_pair = base64.b64decode(b_token, validate=True)
    except base64.binascii.Error as e:
        raise BasicAuthException from e

    try:
        (login, password) = auth_pair.split(b':', maxsplit=1)
    except ValueError as e:
        raise BasicAuthException from e

    try:
        return str(login, encoding=coding), str(password, encoding=coding)
    except UnicodeDecodeError as e:
        raise BasicAuthException from e
Get login + password tuple from Basic Auth token.
biliup/web/http_basic_auth.py