1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

CAPI: Re-auth when Access Token expired: Need to .close() first

The old code did this, and without it we enter a loop of:

1. CAPI says unauthorized
2. We call login()
3. But companion.session.state == STATE_OK, so do nothing
4. Re-scheduled CAPI request goes back to 1.
This commit is contained in:
Athanasius 2021-11-06 08:41:09 +00:00
parent 7a52ddd278
commit 919136874d
No known key found for this signature in database
GPG Key ID: AE3E527847057C7D
2 changed files with 3 additions and 0 deletions

View File

@ -1160,6 +1160,8 @@ class AppWindow(object):
self.status['text'] = _('Frontier CAPI server error')
except companion.CredentialsRequireRefresh:
# We need to 'close' the auth else it'll see STATE_OK and think login() isn't needed
companion.session.close()
# LANG: Frontier CAPI Access Token expired, trying to get a new one
self.status['text'] = _('CAPI: Refreshing access token...')
if companion.session.login():

View File

@ -1210,6 +1210,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
}
except KeyError:
# TODO: Log the exception details too, for some clue about *which* key
logger.error(f"LoadoutEquipModule: {entry}")
elif event_type == 'loadoutremovemodule':