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: bimmer_connected.const.Regions, access_token: Optional[str] = None, expires_at: Optional[datetime.datetime] = None, refresh_token: Optional[str] = None)[source]¶ Authentication for MyBMW API.
-
async_auth_flow
(request: httpx.Request) → AsyncGenerator[httpx.Request, httpx.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.
-
login_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: bimmer_connected.api.client.MyBMWClientConfiguration, *args, brand: Optional[bimmer_connected.const.CarBrands] = None, **kwargs)[source]¶ Async HTTP client based on httpx.AsyncClient with automated OAuth token refresh.
-
class
bimmer_connected.api.client.
MyBMWClientConfiguration
(authentication: bimmer_connected.api.authentication.MyBMWAuthentication, log_responses: Optional[bool] = False, observer_position: Optional[bimmer_connected.models.GPSPosition] = None, use_metric_units: Optional[bool] = True)[source]¶ Stores global settings for MyBMWClient.
-
log_responses
= False¶
-
observer_position
= None¶
-
set_log_responses
(log_responses: bool) → None[source]¶ Set if responses are logged and clear response store.
-
use_metric_units
= True¶
-
bimmer_connected.api.regions
¶
Get the right url for the different countries.
-
bimmer_connected.api.regions.
get_aes_keys
(region: bimmer_connected.const.Regions) → Dict[str, bytes][source]¶ Get the keys for login nonce.
-
bimmer_connected.api.regions.
get_app_version
(region: bimmer_connected.const.Regions) → str[source]¶ Get the app version & build number for the region.
-
bimmer_connected.api.regions.
get_ocp_apim_key
(region: bimmer_connected.const.Regions) → str[source]¶ Get the authorization for OAuth settings.
-
bimmer_connected.api.regions.
get_region_from_name
(name: str) → bimmer_connected.const.Regions[source]¶ Get a region for a string.
This function is not case-sensitive.
bimmer_connected.api.utils
¶
Utils for bimmer_connected.api.
-
bimmer_connected.api.utils.
anonymize_data
(json_data: Union[List[T], Dict[KT, VT]]) → Union[List[T], Dict[KT, VT]][source]¶ Replace parts of the logfiles containing personal information.
-
bimmer_connected.api.utils.
anonymize_response
(response: httpx.Response) → bimmer_connected.models.AnonymizedResponse[source]¶ Anonymize a responses URL and content.
-
bimmer_connected.api.utils.
anonymize_vin
(match: re.Match)[source]¶ Anonymize VINs but keep assignment.
-
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_token
(length: int = 30, chars: str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~') → str[source]¶ Generate a random token with given length and characters.