Fixed bug

This commit is contained in:
Niccolò Zapponi 2020-12-11 09:41:35 +00:00
parent e0f11158e1
commit 94f8ef8aaa
No known key found for this signature in database
GPG key ID: 328B304DC670A51E

View file

@ -104,7 +104,9 @@ class PyiCloudSession(Session):
if not response.ok and (content_type not in json_mimetypes
or response.status_code in [421, 450, 500]):
if has_retried is None and response.status_code == 450 and self.service._get_webservice_url("findme") in url:
try:
fmip_url = self.service._get_webservice_url("findme")
if has_retried is None and response.status_code == 450 and fmip_url in url:
# Handle re-authentication for Find My iPhone
LOGGER.debug("Re-authenticating Find My iPhone service")
try:
@ -113,8 +115,10 @@ class PyiCloudSession(Session):
LOGGER.debug("Re-authentication failed")
kwargs["retried"] = True
return self.request(method, url, **kwargs)
except Exception:
pass
elif has_retried is None and response.status_code in [421, 450, 500]:
if has_retried is None and response.status_code in [421, 450, 500]:
api_error = PyiCloudAPIResponseException(
response.reason, response.status_code, retry=True
)