diff --git a/aiocraft/client.py b/aiocraft/client.py index b9cacf2..27fa26b 100644 --- a/aiocraft/client.py +++ b/aiocraft/client.py @@ -107,12 +107,15 @@ class Client: if self.username and self.password: self.token = await Token.authenticate(self.username, self.password) self._logger.info("Authenticated from credentials") + self._authenticated = True return True raise AuthException("No token or credentials provided") try: await self.token.validate() # will raise an exc if token is invalid + self._authenticated = True except AuthException: await self.token.refresh() + self._authenticated = True self._logger.warning("Refreshed Token") return True @@ -212,6 +215,7 @@ class Client: if packet.__class__ in self._packet_callbacks[self.dispatcher.state]: # callback for this packet for cb in self._packet_callbacks[self.dispatcher.state][packet.__class__]: await cb(packet) + self.dispatcher.incoming.task_done() except asyncio.TimeoutError: pass # need this to recheck self._processing periodically diff --git a/aiocraft/mc/identity.py b/aiocraft/mc/identity.py index 0632b2d..59ee6b1 100644 --- a/aiocraft/mc/identity.py +++ b/aiocraft/mc/identity.py @@ -101,7 +101,7 @@ class Token: async with aiohttp.ClientSession() as sess: async with sess.post(endpoint, headers=cls.HEADERS, data=json.dumps(data).encode('utf-8')) as res: data = await res.json(content_type=None) - logging.info(f"Auth request | {data}") + logging.info(f"Auth request | {res.status} | {data}") if res.status >= 400: raise AuthException(f"Action '{endpoint.rsplit('/',1)[1]}' did not succeed") return data