Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Retry query on 403 after successful handshake #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kasa/klaptransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

from .credentials import Credentials
from .deviceconfig import DeviceConfig
from .exceptions import AuthenticationError, KasaException
from .exceptions import AuthenticationError, KasaException, _RetryableError
from .httpclient import HttpClient
from .json import loads as json_loads
from .protocol import DEFAULT_CREDENTIALS, BaseTransport, get_default_credentials, md5
Expand Down Expand Up @@ -337,7 +337,7 @@ async def send(self, request: str):
# If we failed with a security error, force a new handshake next time.
if response_status == 403:
self._handshake_done = False
raise AuthenticationError(
raise _RetryableError(
f"Got a security error from {self._host} after handshake "
+ "completed"
)
Expand Down
2 changes: 1 addition & 1 deletion kasa/tests/test_klapprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ async def _return_response(url: URL, params=None, data=None, *_, **__):
pytest.param(
(200, 200, 403),
True,
pytest.raises(AuthenticationError),
pytest.raises(_RetryableError),
id="request-403-status",
),
pytest.param(
Expand Down