def connect(fb_constructor, hostname, token=None, username=None, password=None
    ):
    """ Call constructor fb_constructor and log on"""
    if bool(token) == bool(username):
        raise TypeError("If you pass 'token' you cannot supply 'username'")
    if bool(username) != bool(password):
        raise TypeError('username and password should be set both or none')
    if token:
        fb = fb_constructor(hostname, token=token)
    else:
        fb = fb_constructor(hostname)
        fb.logon(username, password)
    return fb
