From 7a52ddd27801fc979d31408e496e3e206adbf93d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 5 Nov 2021 17:57:35 +0000 Subject: [PATCH] CAPI: Add retry of request after refreshing Access Token --- EDMarketConnector.py | 2 ++ companion.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index e561eb24..32e4072a 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1165,6 +1165,8 @@ class AppWindow(object): if companion.session.login(): logger.debug('Initial query failed, but login() just worked, trying again...') companion.session.retrying = True + self.w.after(int(SERVER_RETRY * 1000), lambda: self.capi_request_data(event)) + return # early exit to avoid starting cooldown count except companion.CredentialsError: companion.session.retrying = False diff --git a/companion.py b/companion.py index 7c9cc96a..18b53402 100644 --- a/companion.py +++ b/companion.py @@ -784,7 +784,7 @@ class Session(object): # TODO: This needs to try a REFRESH, not a full re-auth # No need for translation, we'll go straight into trying new Auth # and thus any message would be overwritten. - raise CredentialsError('Frontier CAPI said Auth required') from e + raise CredentialsRequireRefresh('Frontier CAPI said "unauthorized"') from e if r.status_code == 418: # "I'm a teapot" - used to signal maintenance # LANG: Frontier CAPI returned 418, meaning down for maintenance