try/except validate, refresh, login

This commit is contained in:
əlemi 2022-04-18 20:43:48 +02:00
parent 2030bfc97b
commit 3f647bb561
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -73,10 +73,10 @@ class MinecraftClient:
try: try:
await self.authenticator.validate() # will raise an exc if token is invalid await self.authenticator.validate() # will raise an exc if token is invalid
except AuthException: except AuthException:
if self.authenticator.refreshable: try:
await self._authenticator.refresh() await self.authenticator.refresh()
self.logger.warning("Refreshed Token") self.logger.warning("Refreshed Token")
else: except AuthException:
await self.authenticator.login() await self.authenticator.login()
self.logger.info("Logged in") self.logger.info("Logged in")
self._authenticated = True self._authenticated = True