From cc631cdce7ed13569fd9cabec8c522fc20d48d02 Mon Sep 17 00:00:00 2001 From: Gary Cobb Date: Wed, 16 Feb 2022 17:51:28 -0500 Subject: [PATCH] Fix for 450 reauthentication failure bug (#372) Co-authored-by: Paulus Schoutsen --- pyicloud/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index 91ca1d3..6ac8bdb 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -105,13 +105,16 @@ class PyiCloudSession(Session): fmip_url = self.service._get_webservice_url("findme") if ( has_retried is None - and response.status_code == 450 + and response.status_code in [421, 450, 500] and fmip_url in url ): # Handle re-authentication for Find My iPhone LOGGER.debug("Re-authenticating Find My iPhone service") try: - self.service.authenticate(True, "find") + # If 450, authentication requires a full sign in to the account + service = None if response.status_code == 450 else "find" + self.service.authenticate(True, service) + except PyiCloudAPIResponseException: LOGGER.debug("Re-authentication failed") kwargs["retried"] = True