Skip to content

Commit

Permalink
Update app version to 3.9.0 (#573)
Browse files Browse the repository at this point in the history
Co-authored-by: rikroe <rikroe@users.noreply.github.com>
  • Loading branch information
rikroe and rikroe authored Oct 20, 2023
1 parent b267df3 commit 67eb69c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
5 changes: 2 additions & 3 deletions bimmer_connected/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA

from bimmer_connected.api.regions import Regions, get_app_version, get_ocp_apim_key, get_server_url
from bimmer_connected.api.regions import Regions, get_app_version, get_ocp_apim_key, get_server_url, get_user_agent
from bimmer_connected.api.utils import (
create_s256_code_challenge,
generate_cn_nonce,
Expand All @@ -31,7 +31,6 @@
AUTH_CHINA_TOKEN_URL,
HTTPX_TIMEOUT,
OAUTH_CONFIG_URL,
USER_AGENT,
X_USER_AGENT,
)
from bimmer_connected.models import MyBMWAPIError
Expand Down Expand Up @@ -358,7 +357,7 @@ def __init__(self, *args, **kwargs):
region = kwargs.pop("region")
kwargs["base_url"] = get_server_url(region)
kwargs["headers"] = {
"user-agent": USER_AGENT,
"user-agent": get_user_agent(region),
"x-user-agent": X_USER_AGENT.format(brand="bmw", app_version=get_app_version(region), region=region.value),
}

Expand Down
6 changes: 3 additions & 3 deletions bimmer_connected/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import httpx

from bimmer_connected.api.authentication import MyBMWAuthentication
from bimmer_connected.api.regions import get_app_version, get_server_url
from bimmer_connected.api.regions import get_app_version, get_server_url, get_user_agent
from bimmer_connected.api.utils import anonymize_response, get_correlation_id, handle_httpstatuserror
from bimmer_connected.const import HTTPX_TIMEOUT, USER_AGENT, X_USER_AGENT, CarBrands
from bimmer_connected.const import HTTPX_TIMEOUT, X_USER_AGENT, CarBrands
from bimmer_connected.models import AnonymizedResponse, GPSPosition

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -82,7 +82,7 @@ def generate_default_header(self, brand: Optional[CarBrands] = None) -> Dict[str
return {
"accept": "application/json",
"accept-language": "en",
"user-agent": USER_AGENT,
"user-agent": get_user_agent(self.config.authentication.region),
"x-user-agent": X_USER_AGENT.format(
brand=(brand or CarBrands.BMW).value,
app_version=get_app_version(self.config.authentication.region),
Expand Down
7 changes: 6 additions & 1 deletion bimmer_connected/api/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from base64 import b64decode
from typing import List

from bimmer_connected.const import APP_VERSIONS, OCP_APIM_KEYS, SERVER_URLS_MYBMW, Regions
from bimmer_connected.const import APP_VERSIONS, OCP_APIM_KEYS, SERVER_URLS_MYBMW, USER_AGENTS, Regions


def valid_regions() -> List[str]:
Expand All @@ -26,6 +26,11 @@ def get_server_url(region: Regions) -> str:
return f"https://{SERVER_URLS_MYBMW[region]}"


def get_user_agent(region: Regions) -> str:
"""Get the Dart user agent for the region."""
return USER_AGENTS[region]


def get_app_version(region: Regions) -> str:
"""Get the app version & build number for the region."""
return APP_VERSIONS[region]
Expand Down
10 changes: 7 additions & 3 deletions bimmer_connected/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ class Regions(str, Enum):
}

APP_VERSIONS = {
Regions.NORTH_AMERICA: "3.3.1(22418)",
Regions.REST_OF_WORLD: "3.3.1(22418)",
Regions.NORTH_AMERICA: "3.9.0(27760)",
Regions.REST_OF_WORLD: "3.9.0(27760)",
Regions.CHINA: "3.6.1(23634)",
}

HTTPX_TIMEOUT = 30.0

USER_AGENT = "Dart/2.18 (dart:io)"
USER_AGENTS = {
Regions.NORTH_AMERICA: "Dart/2.19 (dart:io)",
Regions.REST_OF_WORLD: "Dart/2.19 (dart:io)",
Regions.CHINA: "Dart/2.18 (dart:io)",
}
X_USER_AGENT = "android(TQ2A.230405.003.B2);{brand};{app_version};{region}"


Expand Down

0 comments on commit 67eb69c

Please sign in to comment.