skodaconnect / homeassistant-skodaconnect

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

Get current consent-status to throw a more cleaner error in the logs #179

Open RamonQu opened 1 year ago

RamonQu commented 1 year ago

I saw quite some people with issues (#174, #175, #176, #178) on the integration which is caused by a missing Consent in the MySkoda App.

I managed to capture the calls which are performed to GET the specific consent-status and POST a confirmation (by accepting the terms). Maybe it would be helpful to check the status of the consent and use it to throw a more cleaner error in the logging.

  1. A GET call is done to https://api.connect.skoda-auto.cz/api/v1/users/[USERID]/identities which returns:

    {
    "identities": [{
        "identity": "MBB",
        "actionsToCompleteIdentity": []
    }, {
        "identity": "DCS",
        "actionsToCompleteIdentity": []
    }, {
        "identity": "CONNECT",
        "actionsToCompleteIdentity": ["GIVE_DOCUMENT_CONSENT"]
    }, {
        "identity": "CABS",
        "actionsToCompleteIdentity": []
    }]
    }

    The GIVE_DOCUMENT_CONSENT is probably the status that prevents further actions to the API to get the car status.

  2. A GET call is done to https://document-consent.vwgroup.io/api/v2/consents/required?document-id=[DOCID]&user-id=[USERID}&locale=en-GB

{
    "consentRequired": true,
    "versionDetails": {
        "id": "[ID]",
        "versionId": "[VERSIONID]",
        "locale": "en-GB",
        "title": "ŠKODA Connect",
        "text": "<br>\n\n### Terms and Conditions\n----------------\nImportant legal terms and information for setting up and using ŠKODA Connect services.\n\n[TERMS AND CONDITIONS ŠKODA CONNECT > ](https://consent.vwgroup.io/consent/v1/texts/SkodaConnect/gb/en/termsOfUse/latest/html)\n\n<br>\n\n### Information on Personal Data Processing\n----------------\nInformation on handling user data across ŠKODA Connect functions.\n\n[INFORMATION ON PERSONAL DATA PROCESSING > ](https://consent.vwgroup.io/consent/v1/texts/SkodaConnect/gb/en/dataprivacy/latest/html)",
        "disclaimer": ""
    },
    "consent": {
        "id": "[ID]",
        "userId": "[USERID]",
        "decision": true,
        "versionDetailsId": "[VERSIONID]",
        "collector": "[COLLECTOR]@apps_vw-dilab_com",
        "updatedAt": "2021-10-14T09:02:53Z",
        "version": 2
    }
}
  1. A POST is done to https://document-consent.vwgroup.io/api/v2/consents to confirm the decision to accept the terms

Payload {"decision":true,"userId":"[USERID]","versionDetailsId":"[VERSIONID]"}

Response

{
    "id": "[NEWID?]",
    "userId": "[USERID]",
    "decision": true,
    "versionDetailsId": "[OTHERVERSIONID],
    "collector": "[COLLECTOR]@apps_vw-dilab_com",
    "updatedAt": "2023-01-15T21:42:35.045Z",
    "version": 3
}
  1. After accepting the terms the first GET call to https://api.connect.skoda-auto.cz/api/v1/users/[USERID]/identities return this response:
{
    "identities": [{
        "identity": "MBB",
        "actionsToCompleteIdentity": []
    }, {
        "identity": "DCS",
        "actionsToCompleteIdentity": []
    }, {
        "identity": "CONNECT",
        "actionsToCompleteIdentity": []
    }, {
        "identity": "CABS",
        "actionsToCompleteIdentity": []
    }]
}
Farfar commented 1 year ago

I saw quite some people with issues (#174, #175, #176, #178) on the integration which is caused by a missing Consent in the MySkoda App.

I managed to capture the calls which are performed to GET the specific consent-status and POST a confirmation (by accepting the terms). Maybe it would be helpful to check the status of the consent and use it to throw a more cleaner error in the logging.

  1. A GET call is done to https://api.connect.skoda-auto.cz/api/v1/users/[USERID]/identities which returns:
{
  "identities": [{
      "identity": "MBB",
      "actionsToCompleteIdentity": []
  }, {
      "identity": "DCS",
      "actionsToCompleteIdentity": []
  }, {
      "identity": "CONNECT",
      "actionsToCompleteIdentity": ["GIVE_DOCUMENT_CONSENT"]
  }, {
      "identity": "CABS",
      "actionsToCompleteIdentity": []
  }]
}

The GIVE_DOCUMENT_CONSENT is probably the status that prevents further actions to the API to get the car status.

  1. A GET call is done to [https://document-consent.vwgroup.io/api/v2/consents/required?document-id=[DOCID]&user-id=[USERID}&locale=en-GB](https://document-consent.vwgroup.io/api/v2/consents/required?document-id=%5BDOCID%5D&user-id=%5BUSERID%7D&locale=en-GB)
{
  "consentRequired": true,
  "versionDetails": {
      "id": "[ID]",
      "versionId": "[VERSIONID]",
      "locale": "en-GB",
      "title": "ŠKODA Connect",
      "text": "<br>\n\n### Terms and Conditions\n----------------\nImportant legal terms and information for setting up and using ŠKODA Connect services.\n\n[TERMS AND CONDITIONS ŠKODA CONNECT > ](https://consent.vwgroup.io/consent/v1/texts/SkodaConnect/gb/en/termsOfUse/latest/html)\n\n<br>\n\n### Information on Personal Data Processing\n----------------\nInformation on handling user data across ŠKODA Connect functions.\n\n[INFORMATION ON PERSONAL DATA PROCESSING > ](https://consent.vwgroup.io/consent/v1/texts/SkodaConnect/gb/en/dataprivacy/latest/html)",
      "disclaimer": ""
  },
  "consent": {
      "id": "[ID]",
      "userId": "[USERID]",
      "decision": true,
      "versionDetailsId": "[VERSIONID]",
      "collector": "[COLLECTOR]@apps_vw-dilab_com",
      "updatedAt": "2021-10-14T09:02:53Z",
      "version": 2
  }
}
  1. A POST is done to https://document-consent.vwgroup.io/api/v2/consents to confirm the decision to accept the terms

Payload {"decision":true,"userId":"[USERID]","versionDetailsId":"[VERSIONID]"}

Response

{
  "id": "[NEWID?]",
  "userId": "[USERID]",
  "decision": true,
  "versionDetailsId": "[OTHERVERSIONID],
  "collector": "[COLLECTOR]@apps_vw-dilab_com",
  "updatedAt": "2023-01-15T21:42:35.045Z",
  "version": 3
}
  1. After accepting the terms the first GET call to https://api.connect.skoda-auto.cz/api/v1/users/[USERID]/identities return this response:
{
  "identities": [{
      "identity": "MBB",
      "actionsToCompleteIdentity": []
  }, {
      "identity": "DCS",
      "actionsToCompleteIdentity": []
  }, {
      "identity": "CONNECT",
      "actionsToCompleteIdentity": []
  }, {
      "identity": "CABS",
      "actionsToCompleteIdentity": []
  }]
}

Yes! This is exactly the type of information I need to improve the integration under these circumstances. I've seen this endpoint being used from version 5.x of the app, it wasn't used in 4.x, it had another endpoint to check valid consent. Now the question is: how to get the document ID. It would be nice to add the functionality to accept from config flow. For starters it should be enough with this information to implement a check that throws a relevant error message.

RamonQu commented 1 year ago

Using MySkoda iOS App 5.3.0 (Build ID000000120, 05-12-2022)

Farfar commented 1 year ago

That's the same version as recent Android which I guess means they use same version numbering now on both platforms.

RamonQu commented 1 year ago

No luck there. I don't see a call that fetches the documentID, so probably it is created of raised from the App itself. But throwing a relevant error message would be helpful for starters. :)

dvx76 commented 9 months ago

Just a note to go check this out and maybe have a way to implement auto-accepting consent:

https://www.npmjs.com/package/iobroker.vw-connect/v/0.0.34

0.0.34

add auto accept of new privacy consent