ReneNulschDE / mbapi2020

Custom Component to integrate MercedesME devices into Home-Assistant
Other
149 stars 29 forks source link

Trying to understand the authentication code #158

Closed dennzs closed 8 months ago

dennzs commented 8 months ago

Hi, I hope this is not a dumb question but I'm trying to understand the code but I can't seem to build a request to send the pin. I'm using something like this with random uuids. Am I missing something or should this work? I just get 400 Bad Request when I POST in Postman.

https://bff.emea-prod.mobilesdk.mercedes-benz.com/v1/login?emailOrPhoneNumber=foo@bar.com&countryCode=EN&nonce=2f833c72-f7e3-4212-af79-62721f5c7a1e

These are my headers: Ris-Os-Name:ios Ris-Os-Version:16.5 Ris-Sdk-Version:2.105.0 X-Locale:en-GB X-Trackingid:d9f19c37-9f0a-4e5b-84a1-9e424f8b3b5b X-Sessionid:cde67a4a-ebf2-4d71-8a61-0d0a77a28c91 User-Agent:MyCar/1.37.0 (com.daimler.ris.mercedesme.ece.ios; build:2001; iOS 17.1.0) Alamofire/5.4.0 Content-Type:application/json X-Applicationname:mycar-store-ece Ris-Application-Version:1.37.0

Thanks for the great custom component!

ReneNulschDE commented 8 months ago

Hi,

looks like your request in postman is not correct.

  1. Make sure the URL does not contain any parameters.
  2. Configure the Body to raw and paste this in the body {"emailOrPhoneNumber" : "foo@bar.com", "countryCode" : "EN", "nonce" : "a616cbd2-900a-4b50-9ea1-4814b432b2ff"}

Please keep in mind that this is not an official API and you should not play with these endpoints.

If you want to better understand the requests, you can enable the proxy function of the component.

  1. Install Burp or a other Dev-proxy-tool
  2. Change the const.py line 72 (verifyssl) to false
  3. comment the const.py line 74, 75
  4. uncomment the const.py line 76-79 and change the values to your proxy setting
  5. restart HA

Dont forget to revert the code changes after you finished the analysis.

dennzs commented 8 months ago

Thank you. This was very helpful and worked like a charm. Much appreciated!