Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the VWID authentication implementation in libvwid.py to use an OIDC hybrid login flow against the newer /auth/v1/idk/oidc/* endpoints in order to resolve login failures.
Changes:
- Switches login flow to OIDC hybrid (
response_type=code id_token token) and updates related headers/endpoints. - Introduces a set of VW-specific exception classes and improves error handling/logging in several request paths.
- Adds additional vehicle/trip endpoints and multiple remote-action helper methods (climate/charging/lock/honk, etc.).
Comments suppressed due to low confidence (2)
packages/modules/vehicles/vwid/libvwid.py:568
doLogin()retry loop will never log/return viaif i > triesbecauserange(tries)yields0..tries-1. This makes the failure branch unreachable and can hide the final-attempt failure path.
for i in range(tries):
self._session_logged_in = await self._login()
if self._session_logged_in:
break
if i > tries:
_LOGGER.error("Login failed after %s tries", tries)
return False
packages/modules/vehicles/vwid/libvwid.py:568
doLogin()retry loop will never log/return viaif i > triesbecauserange(tries)yields0..tries-1. This makes the failure branch unreachable and can hide the final-attempt failure path.
for i in range(tries):
self._session_logged_in = await self._login()
if self._session_logged_in:
break
if i > tries:
_LOGGER.error("Login failed after %s tries", tries)
return False
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
553
to
+554
| def _clear_cookies(self): | ||
| self._session._cookie_jar._cookies.clear() | ||
| self._session._cookie_jar._cookies.clear() # pylint: disable=protected-access |
Comment on lines
+681
to
+684
| # Redirect case | ||
| if not redirect and req.status == 302: | ||
| return req.headers["Location"] | ||
| if req.status != 200: | ||
| raise Exception("Form POST request failed.") | ||
| return await req.text() | ||
| return req.headers.get("Location") | ||
|
|
Comment on lines
+802
to
+809
| auth_code = all_params.get("code", [None])[0] | ||
| id_token = all_params.get("id_token", [None])[0] | ||
| access_token = all_params.get("access_token", [None])[0] | ||
|
|
||
| if not auth_code: | ||
| raise AuthenticationError("No authorization code in callback URL") | ||
|
|
||
| return auth_code, id_token, access_token |
Comment on lines
1152
to
1155
| _LOGGER.debug( | ||
| "Did not receive return data for requested service %s." | ||
| " (This is expected for several service/car combinations)", | ||
| "Did not receive return data for requested service %s.\ | ||
| (This is expected for several service/car combinations)", | ||
| service, |
Comment on lines
+1352
to
+1361
| async def setClimater(self, vin, data, action): | ||
| """Execute climatisation actions.""" | ||
| action = "start" if action else "stop" | ||
| try: | ||
| response_raw = await self.post( | ||
| f"{BASE_API}/vehicle/v1/vehicles/{vin}/climatisation/{action}", | ||
| json=data, | ||
| return_raw=True, | ||
| ) | ||
| return await self._handle_action_result(response_raw) |
Comment on lines
553
to
+554
| def _clear_cookies(self): | ||
| self._session._cookie_jar._cookies.clear() | ||
| self._session._cookie_jar._cookies.clear() # pylint: disable=protected-access |
Comment on lines
+681
to
+684
| # Redirect case | ||
| if not redirect and req.status == 302: | ||
| return req.headers["Location"] | ||
| if req.status != 200: | ||
| raise Exception("Form POST request failed.") | ||
| return await req.text() | ||
| return req.headers.get("Location") | ||
|
|
Comment on lines
+802
to
+809
| auth_code = all_params.get("code", [None])[0] | ||
| id_token = all_params.get("id_token", [None])[0] | ||
| access_token = all_params.get("access_token", [None])[0] | ||
|
|
||
| if not auth_code: | ||
| raise AuthenticationError("No authorization code in callback URL") | ||
|
|
||
| return auth_code, id_token, access_token |
Comment on lines
1152
to
1155
| _LOGGER.debug( | ||
| "Did not receive return data for requested service %s." | ||
| " (This is expected for several service/car combinations)", | ||
| "Did not receive return data for requested service %s.\ | ||
| (This is expected for several service/car combinations)", | ||
| service, |
Comment on lines
+1352
to
+1361
| async def setClimater(self, vin, data, action): | ||
| """Execute climatisation actions.""" | ||
| action = "start" if action else "stop" | ||
| try: | ||
| response_raw = await self.post( | ||
| f"{BASE_API}/vehicle/v1/vehicles/{vin}/climatisation/{action}", | ||
| json=data, | ||
| return_raw=True, | ||
| ) | ||
| return await self._handle_action_result(response_raw) |
Collaborator
Author
|
Interface is not working since today. Closing PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix login problem