Added support to force auth refresh

This commit is contained in:
Niccolò Zapponi 2020-11-09 09:11:14 +00:00
parent 8f1bd9473a
commit 6f0aa0360a
No known key found for this signature in database
GPG key ID: 328B304DC670A51E

View file

@ -256,14 +256,14 @@ class PyiCloudService(object):
self._files = None
self._photos = None
def authenticate(self):
def authenticate(self, force_refresh=False):
"""
Handles authentication, and persists cookies so that
subsequent logins will not cause additional e-mails from Apple.
"""
login_successful = False
if self.session_data.get("session_token"):
if self.session_data.get("session_token") and not force_refresh:
LOGGER.debug("Checking session token validity")
try:
req = self.session.post(f"{self.SETUP_ENDPOINT}/validate", data="null")