From 4864a1d22228735cf44b48f5b2a7ac86dd31b2c1 Mon Sep 17 00:00:00 2001 From: Max Muth Date: Sun, 17 Dec 2023 11:40:58 +0100 Subject: [PATCH] librelinkup: add logging when server region is incorrect Apparently, the LibreLinkUp API has many regions and accounts are expected to use their region-specific API. In such a case, all other regions return a redirect. --- librelinkup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/librelinkup.py b/librelinkup.py index bd8a40f..d628c6b 100644 --- a/librelinkup.py +++ b/librelinkup.py @@ -67,7 +67,11 @@ def append_reading(points, data, reading): data = response.json() if not 'authTicket' in data['data']: - logging.error("Authentication failed") + logging.error("Authentication failed. Server response:") + logging.info(data) + if 'redirect' in data['data'] and data['data']['redirect'] is True: + region = data['data']['region'] + logging.error(f"The LibreLinkUp API returned a redirect. You should try the following url for LIBRELINKUP_URL in config.py: https://api-{region}.libreview.io") sys.exit(1) with open(auth_token_path, 'w') as outfile: