def __init__(self, *clients): if not clients: raise ValueError('No clients provided in DgraphClient constructor') self._clients = clients[:] self._jwt = api.Jwt() self._login_metadata = []
def retry_login(self, timeout=None, metadata=None, credentials=None): if len(self._jwt.refresh_jwt) == 0: raise ValueError('refresh jwt should not be empty') login_req = api.LoginRequest() login_req.refresh_token = self._jwt.refresh_jwt response = self.any_client().login(login_req, timeout=timeout, metadata=metadata, credentials=credentials) self._jwt = api.Jwt() self._jwt.ParseFromString(response.json) self._login_metadata = [("accessjwt", self._jwt.access_jwt)]
def login(self, userid, password, timeout=None, metadata=None, credentials=None): login_req = api.LoginRequest() login_req.userid = userid login_req.password = password response = self.any_client().login(login_req, timeout=timeout, metadata=metadata, credentials=credentials) self._jwt = api.Jwt() self._jwt.ParseFromString(response.json) self._login_metadata = [("accessjwt", self._jwt.access_jwt)]