import base64


def parseBasicAuthToken(token):
    """
    This parses an HTTP Basic Auth token and returns a tuple of (username,
    password).
    """
    # Convert the token into a bytes object so b64 can work with it
    if isinstance(token, str):
        token = token.encode('utf-8')

    # Decode from b64 then bytes
    parsedBytes = base64.b64decode(token)
    parsedString = parsedBytes.decode('utf-8')

    # Split out the username, rejoin the password if it had colons
    username, *passwordParts = parsedString.split(':')
    password = ':'.join(passwordParts)

    return (username, password)