From bd46b52f3b90d579cae217df3bc005a9b6c54d78 Mon Sep 17 00:00:00 2001 From: 0x3d Date: Wed, 7 Feb 2024 12:36:22 +0100 Subject: [PATCH] =?UTF-8?q?The=20"op"=20in=20"mym**op**"=20stands=20for=20?= =?UTF-8?q?Opel=20=F0=9F=98=85=20=F0=9F=A4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- psa_car_controller/psa/oauth.py | 4 ++-- psa_car_controller/psa/setup/app_decoder.py | 4 ++-- psa_car_controller/psacc/application/psa_client.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/psa_car_controller/psa/oauth.py b/psa_car_controller/psa/oauth.py index bd15f96..6577f0a 100644 --- a/psa_car_controller/psa/oauth.py +++ b/psa_car_controller/psa/oauth.py @@ -35,8 +35,8 @@ class OpenIdCredentialManager(CredentialManager): challenge = encoded.decode('ascii')[:-1] return verifier, challenge - def init_with_country_code(self, country_code: str): - redir_uri = "mymop://oauth2redirect/" + country_code.lower() + def init_with_brand_country_code(self, brand: str, country_code: str): + redir_uri = "mym" + brand.lower() + "://oauth2redirect/" + country_code.lower() code_verifier, code_challenge = self.generate_sha256_pkce(64) url = self.generate_authorize_url(redir_uri, secrets.token_urlsafe(16), code_challenge=code_challenge, code_challenge_method="S256") diff --git a/psa_car_controller/psa/setup/app_decoder.py b/psa_car_controller/psa/setup/app_decoder.py index 3694fd9..cd475ec 100755 --- a/psa_car_controller/psa/setup/app_decoder.py +++ b/psa_car_controller/psa/setup/app_decoder.py @@ -91,8 +91,8 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, # Psacc psacc = PSAClient(None, apk_parser.client_id, apk_parser.client_secret, None, customer_id, BRAND[package_name]["realm"], - country_code) - psacc.connect(country_code) + country_code, BRAND[package_name]["brand_code"]) + psacc.connect() psacc.save_config(name=config_prefix + "config.json") res = psacc.get_vehicles() diff --git a/psa_car_controller/psacc/application/psa_client.py b/psa_car_controller/psacc/application/psa_client.py index 4fefd3f..67c3c62 100644 --- a/psa_car_controller/psacc/application/psa_client.py +++ b/psa_car_controller/psacc/application/psa_client.py @@ -31,12 +31,12 @@ logger = CustomLogger.getLogger(__name__) class PSAClient: - def connect(self, country_code): - self.manager.init_with_country_code(country_code) + def connect(self): + self.manager.init_with_brand_country_code(self.brand, self.country_code) # pylint: disable=too-many-arguments def __init__(self, refresh_token, client_id, client_secret, remote_refresh_token, customer_id, realm, country_code, - proxies=None, weather_api=None, abrp=None, co2_signal_api=None): + brand=None, proxies=None, weather_api=None, abrp=None, co2_signal_api=None): self.realm = realm self.service_information = ServiceInformation(AUTHORIZE_SERVICE[self.realm], realm_info[self.realm]['oauth_url'], @@ -60,6 +60,7 @@ class PSAClient: self._record_enabled = False self.weather_api = weather_api self.country_code = country_code + self.brand = brand self.info_callback = [] self.info_refresh_rate = 120 if abrp is None: