def login(self, username, password, login_token=None):
        if login_token is None:
            token_doc = self.post(action='query', meta='tokens', type='login')
            login_token = token_doc['query']['tokens']['logintoken']
        login_doc = self.post(
            action="clientlogin", username=username, password=password,
            logintoken=login_token, loginreturnurl="http://example.org/")
        if login_doc['clientlogin']['status'] == "UI":
            raise ClientInteractionRequest.from_doc(
                login_token, login_doc['clientlogin'])
        elif login_doc['clientlogin']['status'] != 'PASS':
            raise LoginError.from_doc(login_doc['clientlogin'])
        return login_doc['clientlogin']