From 40fe4ee5a6ae5b2995b6b56acf6148171d939767 Mon Sep 17 00:00:00 2001 From: Sander Peterse Date: Thu, 1 Jun 2023 13:09:25 +0200 Subject: [PATCH 1/3] Use a unique user agent for each client as a workaround for #119 --- pyIndego/const.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyIndego/const.py b/pyIndego/const.py index 7ba1840..517ace2 100644 --- a/pyIndego/const.py +++ b/pyIndego/const.py @@ -1,6 +1,7 @@ """Constants for pyIndego.""" from enum import Enum - +import random +import string class Methods(Enum): """Enum with HTTP methods.""" @@ -23,7 +24,8 @@ class Methods(Enum): CONTENT_TYPE: CONTENT_TYPE_JSON, # We need to change the user-agent! # The Microsoft Azure proxy seems to block all requests (HTTP 403) for the default 'python-requests' user-agent. - "User-Agent": "pyIndego" + # We also need to use a random agent for each client: https://github.com/jm-73/pyIndego/issues/119 + "User-Agent": "pyIndego-" + ''.join(random.choices(string.ascii_uppercase + string.digits, k=12)) } DEFAULT_LOOKUP_VALUE = "Not in database." From 6e9a8ffb2666ea7a94ddc5906be4ff897cb1c449 Mon Sep 17 00:00:00 2001 From: Sander Peterse Date: Thu, 1 Jun 2023 13:11:47 +0200 Subject: [PATCH 2/3] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8f32b9b..afdce57 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="pyIndego", - version="2.2.1", + version="2.2.2", author="jm-73, sander1988", author_email="jens@myretyr.se", description="API for Bosch Indego mower", From c270bf5cf2d9a549c33a960523f8211aec997fac Mon Sep 17 00:00:00 2001 From: Sander Peterse Date: Thu, 1 Jun 2023 13:22:01 +0200 Subject: [PATCH 3/3] User agent needs to be fully unique ; or it's still getting blocked with 403 (#119). --- pyIndego/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyIndego/const.py b/pyIndego/const.py index 517ace2..e27ecf6 100644 --- a/pyIndego/const.py +++ b/pyIndego/const.py @@ -25,7 +25,7 @@ class Methods(Enum): # We need to change the user-agent! # The Microsoft Azure proxy seems to block all requests (HTTP 403) for the default 'python-requests' user-agent. # We also need to use a random agent for each client: https://github.com/jm-73/pyIndego/issues/119 - "User-Agent": "pyIndego-" + ''.join(random.choices(string.ascii_uppercase + string.digits, k=12)) + "User-Agent": ''.join(random.choices(string.ascii_uppercase + string.digits, k=12)) } DEFAULT_LOOKUP_VALUE = "Not in database."