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

Retrying setup: API token request returned with status code 401 #114

Closed zaubererty closed 2 years ago

zaubererty commented 2 years ago

Describe the bug Seams the legacy API is no longer handled correct

Latest working release Current

Debug logs 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Get authorization page: "https://identity.vwgroup.io/oidc/v1/authorize" 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Got authorization endpoint: "https://identity.vwgroup.io/signin-service/v1/signin/f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com?relayState=22c4463fea047d890e1c4abaf120c4af17fa0d3d" 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Got redirect to signin-service 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Extracted form attribute: ('_csrf', 'c4aa16a4-85c6-45f3-8890-d203cc1868f3') 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Extracted form attribute: ('relayState', '22c4463fea047d890e1c4abaf120c4af17fa0d3d') 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Extracted form attribute: ('hmac', '5dea80011d1512b9b134065f07815cb174480a018baee5c93257653ba1fdc8f1') 2022-03-09 13:30:32 DEBUG (MainThread) [skodaconnect.connection] Start authorization for user zieglert@gmx.ch 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Found dynamic credentials form, extracting attributes 2022-03-09 13:30:33 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': '4cc7c4e338c4a83bd669b45547528a6b95ff960867e6a5caa5d54f1285bde085', 'useClientRendering': True, 'emailPasswordForm': {'email': 'email@domain.com', 'password': None}, 'error': None, 'relayState': '22c4463fea047d890e1c4abaf120c4af17fa0d3d', 'nextButtonDisabled': False, 'enableNextButtonAfterSeconds': 0, 'postAction': 'login/authenticate', 'identifierUrl': 'login/identifier'} 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Finalizing login 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Using login action url: "https://identity.vwgroup.io/signin-service/v1/f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com/login/authenticate" 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Following redirect to "https://identity.vwgroup.io/oidc/v1/oauth/sso?clientId=f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com&relayState=22c4463fea047d890e1c4abaf120c4af17fa0d3d&userId=8c9a2806-bc44-4575-93e8-b552d4b26829&HMAC=b0a3d71c7d4ff578dc227db67e5a7300e55891656a0cfe6201acf9c4f30bd418" 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Following redirect to "https://identity.vwgroup.io/signin-service/v1/consent/users/8c9a2806-bc44-4575-93e8-b552d4b26829/f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com?scopes=openid%20mbb%20profile&relayState=22c4463fea047d890e1c4abaf120c4af17fa0d3d&callback=https://identity.vwgroup.io/oidc/v1/oauth/client/callback&hmac=09397ca690d32ad197173f6084530e20b2716241c4780d2559defd7ae26ca64d" 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Following redirect to "https://identity.vwgroup.io/oidc/v1/oauth/client/callback/success?user_id=8c9a2806-bc44-4575-93e8-b552d4b26829&client_id=f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com&scopes=openid%20mbb%20profile&consentedScopes=openid%20mbb%20profile&relayState=22c4463fea047d890e1c4abaf120c4af17fa0d3d&hmac=6cae527634c7c8c8c0278a1f57cd749f2f23ab6e4522cf3be339914fdba4a90c" 2022-03-09 13:30:33 DEBUG (MainThread) [skodaconnect.connection] Received authorization code, exchange for tokens. 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got access_token for client f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com, token: "ACCESS_TOKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got refresh_token for client f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com, token: "REFRESH_TOKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got id_token for client f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com, token: "ID_TOKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Verifying token for f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Matching f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com against 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Matching f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com against f9a2359a-b776-46d9-bd0c-db1904343117@apps_vw-dilab_com 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Token for skoda verified OK. 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Client "connect" token is missing, call to authorize the client. 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Starting authorization process for client connect 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Get authorization page: "https://identity.vwgroup.io/oidc/v1/authorize" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got authorization endpoint: "https://identity.vwgroup.io/oidc/v1/oauth/sso?clientId=7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com&userId=8c9a2806-bc44-4575-93e8-b552d4b26829&relayState=e0a8b687a5908b7777c00edd48af57f27dab1b65&HMAC=41f78fe2734c44f3953f95b535a644150638ca8d6ce385b6437acafd69ece5fa" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Following redirect to "https://identity.vwgroup.io/signin-service/v1/consent/users/8c9a2806-bc44-4575-93e8-b552d4b26829/7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com?scopes=openid%20profile%20address%20cars%20email%20birthdate%20badge%20mbb%20phone%20driversLicense%20dealers%20profession%20vin&relayState=e0a8b687a5908b7777c00edd48af57f27dab1b65&callback=https://identity.vwgroup.io/oidc/v1/oauth/client/callback&hmac=97cbbd821c008fac10cb1aebce10f5667ef9dc2c8b29a46d09e50d4ab78693c8" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Following redirect to "https://identity.vwgroup.io/oidc/v1/oauth/client/callback/success?user_id=8c9a2806-bc44-4575-93e8-b552d4b26829&client_id=7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com&scopes=openid%20profile%20address%20cars%20email%20birthdate%20badge%20mbb%20phone%20driversLicense%20dealers%20profession%20vin&consentedScopes=openid%20profile%20address%20cars%20email%20birthdate%20badge%20mbb%20phone%20driversLicense%20dealers%20profession%20vin&relayState=e0a8b687a5908b7777c00edd48af57f27dab1b65&hmac=50c31240d9cfad864fcb37488795670a142b5ffa7ccc281fbaade5a1a5fff08d" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Received authorization code, exchange for tokens. 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got access_token for client 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com, token: "ACCESS_TOKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got refresh_token for client 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com, token: "REFRESH_TOKKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Got id_token for client 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com, token: "ID_TOKEN" 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Verifying token for 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Matching 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com against 7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] Token for connect verified OK. 2022-03-09 13:30:34 DEBUG (MainThread) [skodaconnect.connection] HTTP POST "https://profileintegrityservice.apps.emea.vwapps.io/iaa/pic/v1/users/8c9a2806-bc44-4575-93e8-b552d4b26829/check-profile" 2022-03-09 13:30:35 DEBUG (MainThread) [skodaconnect.connection] Request for "https://profileintegrityservice.apps.emea.vwapps.io/iaa/pic/v1/users/user/check-profile" returned with status code [200], response: {'scopeId': 'commonMandatoryFields', 'ssoId': 'SSOID', 'missingMandatoryFields': [], 'mbbUserId': 'UserID', 'mbbIdStatus': True, 'mandatoryFieldsStatus': True, 'spinStatus': True, 'mandatoryConsentInfo': [{'id': 'termsOfUse', 'status': 'VALID'}]} 2022-03-09 13:30:35 DEBUG (MainThread) [skodaconnect.connection] Consent returned {'consentInfo': {'scopeId': 'commonMandatoryFields', 'ssoId': '8c9a2806-bc44-4575-93e8-b552d4b26829', 'missingMandatoryFields': [], 'mbbUserId': 'UserID', 'mbbIdStatus': True, 'mandatoryFieldsStatus': True, 'spinStatus': True, 'mandatoryConsentInfo': [{'id': 'termsOfUse', 'status': 'VALID'}]}} 2022-03-09 13:30:35 DEBUG (MainThread) [skodaconnect.connection] User consent is valid, no missing information for profile 2022-03-09 13:30:35 DEBUG (MainThread) [skodaconnect.connection] HTTP GET "https://api.connect.skoda-auto.cz/api/v2/garage/vehicles" 2022-03-09 13:30:36 DEBUG (MainThread) [skodaconnect.connection] Request for "https://api.connect.skoda-auto.cz/api/v2/garage/vehicles" returned with status code [200], response: [] 2022-03-09 13:30:36 DEBUG (MainThread) [skodaconnect.connection] Skoda native API returned no vehicles. Using fallback VW-Group API. 2022-03-09 13:30:36 DEBUG (MainThread) [skodaconnect.connection] Client "vwg" token is missing, call to authorize the client. 2022-03-09 13:30:36 DEBUG (MainThread) [skodaconnect.connection] Trying to fetch api tokens. 2022-03-09 13:30:37 DEBUG (MainThread) [skodaconnect.connection] API token request failed. 2022-03-09 13:30:37 WARNING (MainThread) [homeassistant.config_entries] Config entry 'VIN' for skodaconnect integration not ready yet: API token request returned with status code 401; Retrying in background

Installation:

Additional context Add any other context about the problem here.

Farfar commented 2 years ago

There has been outages this past week. Is the issue still there? If that's the case, can you verify that skoda-connect.com shows your vehicle and that the MySkoda app also works after logout/login?

zaubererty commented 2 years ago

Still the same, app and website are OK.

zaubererty commented 2 years ago

There is some information in the LOG Client "vwg" token is missing, call to authorize the client. This is might the reason for not working

Farfar commented 2 years ago

There is some information in the LOG Client "vwg" token is missing, call to authorize the client. This is might the reason for not working

Yes it fails to fetch the token required to access the API for "legacy" cars. Not sure why since it's working fine here. Might be an issue with the scope requested for the client but either way I cannot reproduce. You can try the example python code from the library and see if that gets you any further.

zaubererty commented 2 years ago

I'll try

zaubererty commented 2 years ago

Could resolve the issue by recreating the account