Fixes Panasonic auth breaking changes #45
Merged
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.
This pull request primarily focuses on enhancing the authentication process due to the Panasonic changes (18th of March 2024) in the
aioaquarea
package. The changes include the addition of a new constant for client ID, importing new modules, and significant modifications to thecore.py
file to handle the enhanced authentication process. The changes also include the introduction of a new optional access token and modifications to therequest
method to handle external URLs.Thanks to @bimusiek for sharing his Typescript implementation in https://github.com/Hernas/homebridge-panasonic-heat-pump
Enhancements to authentication:
aioaquarea/const.py
: Added a new constantAQUAREA_SERVICE_AUTH_CLIENT_ID
for client ID.Imports and Initializations:
aioaquarea/core.py
: Imported there
andhtml
modules.aioaquarea/core.py
: Imported the new constantAQUAREA_SERVICE_AUTH_CLIENT_ID
.aioaquarea/core.py
: Initialized a new optional access token_access_token
in the__init__
method.Modifications to existing methods:
aioaquarea/core.py
: Modified theis_logged
method to check for_access_token
instead of_token_expiration
.aioaquarea/core.py
: Modified therequest
method to handle optional parametersurl
andexternal_url
, and added logic to check for access token and expiration time in the response. [1] [2]aioaquarea/core.py
: Modified thelook_for_errors
method to accept a dictionary instead of a response object.Major changes to the authentication process:
aioaquarea/core.py
: Extensively modified the_login_production
method to handle the enhanced authentication process, which includes multiple requests to different URLs, parsing responses, and handling various scenarios.This pull request primarily focuses on improving the authentication process and updating the request handling in the
aioaquarea
package. The changes include the addition of a new constant for client ID, the introduction of an access token for user authentication, and modifications to the request method to handle external URLs and access tokens. Additionally, the login process has been significantly revamped to handle a more complex authentication flow.Here are the most important changes:
New Constants and Imports:
aioaquarea/const.py
: AddedAQUAREA_SERVICE_AUTH_CLIENT_ID
constant for client authentication.aioaquarea/core.py
: Importedre
andhtml
modules for regular expression and HTML utilities.Authentication Enhancements:
aioaquarea/core.py
: Introduced_access_token
as an optional string in the__init__
method for user authentication.aioaquarea/core.py
: Modified theis_logged
method to use_access_token
instead of_token_expiration
to determine if the user is logged in.Request Handling Updates:
aioaquarea/core.py
: Updated therequest
method to accept optional parametersurl
andexternal_url
to handle requests to external URLs. The method now also checks for an access token in the response and updates_access_token
and_token_expiration
accordingly. [1] [2]aioaquarea/core.py
: Modified thelook_for_errors
method to accept a dictionarydata
instead ofresponse
to handle error checking.Login Process Revamp:
aioaquarea/core.py
: The_login_production
method has been extensively updated to handle a more complex authentication flow. This includes multiple requests to authenticate the user, extract necessary information from responses, and handle errors related to invalid user credentials.