Skip to content

Commit

Permalink
Merge pull request snaptec#2825 from rleidner/soc_smarteq_p6
Browse files Browse the repository at this point in the history
2FA: update versions,  pre request_pin: add config get
  • Loading branch information
LKuemmel authored Apr 5, 2024
2 parents eb5e072 + 8b9bd89 commit 1da98a4
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions modules/soc_smarteq/soc_smarteq_2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import urllib
import uuid


# Constants
BASE_URL = "https://id.mercedes-benz.com"
TOKEN_URL = BASE_URL + "/as/token.oauth2"
Expand All @@ -20,17 +19,17 @@
SCOPE = "openid+profile+email+phone+ciam-uid+offline_access"
CLIENT_ID = "70d89501-938c-4bec-82d0-6abb550b0825"
GUID = "280C6B55-F179-4428-88B6-E0CCF5C22A7C"
ACCEPT_LANGUAGE = "de-de"
ACCEPT_LANGUAGE = "de-DE;q=1.0"
SSL_VERIFY_STATUS = True
LOGIN_APP_ID = "01398c1c-dc45-4b42-882b-9f5ba9f175f1"
COUNTRY_CODE = "DE"
X_APPLICATIONNAME_ECE = "mycar-store-ece"
RIS_APPLICATION_VERSION = "1.39.0 (2066)"
RIS_APPLICATION_VERSION = "1.40.0 (2097)"
RIS_OS_NAME = "ios"
RIS_OS_VERSION = "16.5"
RIS_SDK_VERSION = "2.109.0"
RIS_OS_VERSION = "17.3"
RIS_SDK_VERSION = "2.111.1"
X_LOCALE = "de-DE"
WEBSOCKET_USER_AGENT = "MyCar/1.30.1 (com.daimler.ris.mercedesme.ece.ios; build:1819; iOS 16.5.0) Alamofire/5.4.0"
WEBSOCKET_USER_AGENT = "MyCar/1.40.0 (com.daimler.ris.mercedesme.ece.ios; build:2097; iOS 17.3.0) Alamofire/5.4.0"
STATUS_USER_AGENT = "Device: iPhone 6; OS-version: iOS_12.5.1; App-Name: smart EQ control; App-Version: 3.0;\
Build: 202108260942; Language: de_DE"
CONTENT_TYPE_OAUTH = "application/x-www-form-urlencoded"
Expand Down Expand Up @@ -164,35 +163,41 @@ def set_vin(self, vin: str):
def set_chargepoint(self, chargepoint: str):
self.chargepoint = chargepoint


# 2fa authentication functions
# send request for new pin to oauth server
def request_pin(self, email: str, nonce: str):
self.log.debug("Start request_pin: email=" + email + ", nonce=" + nonce)

url = STATUS_URL_MERCEDES + "/v1/login"
d = {
"emailOrPhoneNumber": self.username,
"countryCode": self._country_code,
"nonce": nonce
}
data = json.dumps(d)

headers = {
"Host": "bff.emea-prod.mobilesdk.mercedes-benz.com",
"Ris-Os-Name": RIS_OS_NAME,
"Ris-Os-Version": RIS_OS_VERSION,
"Ris-Sdk-Version": RIS_SDK_VERSION,
"X-Locale": X_LOCALE,
"Accept": ACCEPT,
"Accept-Language": ACCEPT_LANGUAGE,
"X-Trackingid": str(uuid.uuid4()),
"X-Sessionid": str(uuid.uuid4()),
"X-Requestid": str(uuid.uuid4()),
"device-id": str(uuid.uuid4()),
"User-Agent": WEBSOCKET_USER_AGENT,
"Content-Type": CONTENT_TYPE,
"X-Applicationname": X_APPLICATIONNAME_ECE,
"Ris-Application-Version": RIS_APPLICATION_VERSION,
"X-Authmode": "KEYCLOAK"
"Accept": ACCEPT,
"Accept-Encoding": "gzip, deflate, br",
"Ris-Application-Version": RIS_APPLICATION_VERSION
}

url = STATUS_URL_MERCEDES + "/v1/config"
self.log.info("request_pin-get: url=" + url +
", headers=" + json.dumps(headers, indent=4))
response1 = self.session.get(url, headers=headers)
self.log.info("Result request_pin get: %s", response1)

url = STATUS_URL_MERCEDES + "/v1/login"
d = {
"emailOrPhoneNumber": self.username,
"countryCode": self._country_code,
"nonce": nonce
}
data = json.dumps(d)

self.log.info("request_pin-post: url=" + url +
", data=" + json.dumps(data, indent=4) +
Expand Down

0 comments on commit 1da98a4

Please sign in to comment.