bimmer_connected.api
The bimmer_connected.api
module contains helper functions to communicate with the BMW APIs.
bimmer_connected.api.authentication
Authentication management for BMW APIs.
- class bimmer_connected.api.authentication.MyBMWAuthentication(username: str, password: str, region: Regions, access_token: str | None = None, expires_at: datetime | None = None, refresh_token: str | None = None, gcid: str | None = None, verify: str | bool | SSLContext = True)[source]
Authentication and Retry Handler for MyBMW API.
- async async_auth_flow(request: Request) AsyncGenerator[Request, Response] [source]
Execute the authentication flow asynchronously.
By default, this defers to .auth_flow(). You should override this method when the authentication scheme does I/O and/or uses concurrency primitives.
- property login_lock: Lock
Make sure that there is a lock in the current event loop.
- class bimmer_connected.api.authentication.MyBMWLoginClient(*args, **kwargs)[source]
Async HTTP client based on httpx.AsyncClient with automated OAuth token refresh.
- class bimmer_connected.api.authentication.MyBMWLoginRetry[source]
httpx.Auth used as workaround to retry & sleep on 429 Too Many Requests.
bimmer_connected.api.client
Generic API management.
- class bimmer_connected.api.client.MyBMWClient(config: MyBMWClientConfiguration, *args, brand: CarBrands | None = None, **kwargs)[source]
Async HTTP client based on httpx.AsyncClient with automated OAuth token refresh.
- class bimmer_connected.api.client.MyBMWClientConfiguration(authentication: MyBMWAuthentication, log_responses: bool | None = False, observer_position: GPSPosition | None = None, verify: str | bool | SSLContext = True)[source]
Stores global settings for MyBMWClient.
- authentication: MyBMWAuthentication
- log_responses: bool | None = False
- observer_position: GPSPosition | None = None
- set_log_responses(log_responses: bool) None [source]
Set if responses are logged and clear response store.
- verify: str | bool | SSLContext = True
bimmer_connected.api.regions
Get the right url for the different countries.
- bimmer_connected.api.regions.get_app_version(region: Regions) str [source]
Get the app version & build number for the region.
- bimmer_connected.api.regions.get_ocp_apim_key(region: Regions) str [source]
Get the authorization for OAuth settings.
- bimmer_connected.api.regions.get_region_from_name(name: str) Regions [source]
Get a region for a string.
This function is not case-sensitive.
- bimmer_connected.api.regions.get_server_url(region: Regions) str [source]
Get the url of the server for the region.
bimmer_connected.api.utils
Utils for bimmer_connected.api.
- bimmer_connected.api.utils.anonymize_data(json_data: List | Dict) List | Dict [source]
Replace parts of the logfiles containing personal information.
- bimmer_connected.api.utils.anonymize_response(response: Response) AnonymizedResponse [source]
Anonymize a responses URL and content.
- bimmer_connected.api.utils.create_s256_code_challenge(code_verifier: str) str [source]
Create S256 code_challenge with the given code_verifier.
- bimmer_connected.api.utils.generate_cn_nonce(username: str) str [source]
Generate a x-login-nonce string.
- bimmer_connected.api.utils.generate_random_base64_string(size: int) str [source]
Generate a random base64 string with size.
- bimmer_connected.api.utils.generate_token(length: int = 30, chars: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~') str [source]
Generate a random token with given length and characters.
- bimmer_connected.api.utils.get_capture_position(base64_background_img: str) str [source]
Get the position of the capture in the background image.
- bimmer_connected.api.utils.get_correlation_id() Dict[str, str] [source]
Generate corrlation headers.