skodaconnect / homeassistant-skodaconnect

Skoda Connect - A home assistant plugin to add integration with your car
Apache License 2.0
232 stars 28 forks source link

Skoda Connect login #134

Closed renejorissen closed 2 years ago

renejorissen commented 2 years ago

I installed the integration via HACS. When I add the integration, I have to enter my credentials. Next the integration is trying to sign in: "Logging in to Skoda Connect".

After a few minutes I receive an error message: "Could not login to Skoda Connect, please check your credentials and verify that the service is working"

I am 100% sure that the credentials are correct. I checked them via a regular browser and by signing in to the app.

Farfar commented 2 years ago

Could you please provide logs from homeassistant.log as well? It could be that the service was actually not working at the time but I need to see logs to know where the problem lies.

renejorissen commented 2 years ago

hello,

This is what I can see in the homeassistant.log:

2022-09-14 14:09:23.482 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/skodaconnect/config_flow.py", line 102, in _async_task_login
    if result is False:
UnboundLocalError: local variable 'result' referenced before assignment
2022-09-14 14:12:37.970 ERROR (MainThread) [skodaconnect.connection] Login failed for <mail address>, 

Regards

Farfar commented 2 years ago

hello,

This is what I can see in the homeassistant.log:

2022-09-14 14:09:23.482 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/skodaconnect/config_flow.py", line 102, in _async_task_login
    if result is False:
UnboundLocalError: local variable 'result' referenced before assignment
2022-09-14 14:12:37.970 ERROR (MainThread) [skodaconnect.connection] Login failed for <mail address>, 

Regards

I will need more logs than the last error. Please take a look under https://github.com/lendy007/homeassistant-skodaconnect#enable-debug-logging and provide debug logs for skodaconnect. The login, or authorization, fails but I can't see why without the debugs.

renejorissen commented 2 years ago

Hi,

This is the logging I get after enabling the DEBUG logging.

2022-09-14 20:50:03.184 DEBUG (MainThread) [custom_components.skodaconnect.config_flow] Creating connection to Skoda Connect
2022-09-14 20:50:03.185 INFO (MainThread) [skodaconnect.connection] Init Skoda Connect library, version 1.1.23
2022-09-14 20:50:03.185 DEBUG (MainThread) [skodaconnect.connection] Using service https://msg.volkswagen.de
2022-09-14 20:50:03.186 INFO (MainThread) [skodaconnect.connection] Initiating new login
2022-09-14 20:50:03.186 DEBUG (MainThread) [skodaconnect.connection] Starting authorization process for client skoda
2022-09-14 20:50:03.492 DEBUG (MainThread) [skodaconnect.connection] Got redirect to signin-service
2022-09-14 20:50:03.770 DEBUG (MainThread) [skodaconnect.connection] Start authorization for user <mail address>
2022-09-14 20:50:03.890 DEBUG (MainThread) [skodaconnect.connection] Found dynamic credentials form, extracting attributes
2022-09-14 20:50:03.891 DEBUG (MainThread) [skodaconnect.connection] JSON: {'clientLegalEntityModel': {'clientId': 'f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com', 'clientAppName': 'ŠKODA App & Portal', 'clientAppDisplayName': 'ŠKODA App & Portal', 'legalEntityInfo': {'name': 'ŠKODA', 'shortName': 'SKODA', 'productName': 'ŠKODA ID', 'theme': 'skoda', 'defaultLanguage': 'cs', 'termAndConditionsType': 'DEFAULT', 'legalProperties': {'revokeDataContact': 'DPOffice@skoda-auto.cz', 'imprintText': 'IMPRINT', 'countryOfJurisdiction': 'CZ'}}, 'imprintTextKey': 'imprint.link.text'}, 'template': 'loginAuthenticate', 'hmac': '73efba9c53ebc9e3b78fea780c0bc350cb759f7b6c8ade263eb9d9ef1f2a750a', 'useClientRendering': True, 'emailPasswordForm': {'@class': 'com.volkswagen.identitykit.signin.web.flows.base.model.EmailPasswordForm', 'email': '<mail address>', 'password': None}, 'error': None, 'relayState': '0872a122300160bb9557d600f58158c2c87928cd', 'nextButtonDisabled': False, 'enableNextButtonAfterSeconds': 0, 'postAction': 'login/authenticate', 'identifierUrl': 'login/identifier'}
2022-09-14 20:50:03.891 DEBUG (MainThread) [skodaconnect.connection] Finalizing login
2022-09-14 20:50:04.411 DEBUG (MainThread) [skodaconnect.connection] Received authorization code, exchange for tokens.
2022-09-14 20:55:04.971 ERROR (MainThread) [skodaconnect.connection] Login failed for <mail address>, 
Farfar commented 2 years ago

This is the logging I get after enabling the DEBUG logging.

Do you have the MySkoda app installed on Android or iPhone? There's issues for iPhone only users since the library is built on reverse engineered Android app. I wonder if this problem is one of them.

Otherwise I'm not sure what the problem might be. The part where the login process errors out is where it's trying to get valid tokens for access to the API. After "Login failed for , " there should have been an error message that could have pointed at which part of the code that causes the error.

renejorissen commented 2 years ago

Hello,

I am a iPhone-only user. Do you suggest I login once with an Android device and the SkodaConnect app?

Regards

Farfar commented 2 years ago

Yes please try login on an Android device. If this is part of the issue then you will probably get to accept EULA again. After you have logged on with android please try the integration again. I'm not that confident that it's the solution but it can't hurt. I will also add more log points in next version to try and pinpoint the issue if it persists.

renejorissen commented 2 years ago

Hi,

Logging in on an Android device did the trick. I had to accept the EULA message. After this action and reloading HASS, I was able to add the integration, log in and receive data.

Thnx for the support!