errors
This commit is contained in:
@@ -20,6 +20,10 @@ class MyWhooshAuthError(MyWhooshError):
|
||||
pass
|
||||
|
||||
|
||||
class MyWhooshDeviceConflictError(MyWhooshAuthError):
|
||||
pass
|
||||
|
||||
|
||||
class MyWhooshTransientError(MyWhooshError):
|
||||
pass
|
||||
|
||||
@@ -52,7 +56,7 @@ class MyWhooshClient:
|
||||
"Platform": "Android",
|
||||
"Action": 1001,
|
||||
"CorrelationId": str(uuid.uuid4()),
|
||||
"DeviceId": str(uuid.uuid4()),
|
||||
"DeviceId": self.token_store.get_or_create_device_id(),
|
||||
"Authorization": "",
|
||||
}
|
||||
try:
|
||||
@@ -70,7 +74,10 @@ class MyWhooshClient:
|
||||
if not isinstance(body, dict):
|
||||
raise MyWhooshIntegrationError("MyWhoosh login response is not a JSON object")
|
||||
if body.get("Success") is not True or not body.get("AccessToken"):
|
||||
raise MyWhooshAuthError(str(body.get("Message") or "MyWhoosh login failed"))
|
||||
message = str(body.get("Message") or "MyWhoosh login failed")
|
||||
if "another device" in message.lower():
|
||||
raise MyWhooshDeviceConflictError(message)
|
||||
raise MyWhooshAuthError(message)
|
||||
self.token = MyWhooshToken(
|
||||
access_token=str(body["AccessToken"]),
|
||||
refresh_token=str(body["RefreshToken"]) if body.get("RefreshToken") else None,
|
||||
|
||||
Reference in New Issue
Block a user