Skip to content

Commit 415256e

Browse files
committed
Add a new exception for 'refresh token expired'.
1 parent b4f1475 commit 415256e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

pyhiveapi/apyhiveapi/api/hive_auth_async.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
HiveInvalidDeviceAuthentication,
2222
HiveInvalidPassword,
2323
HiveInvalidUsername,
24+
HiveRefreshTokenExpired,
2425
)
2526
from .hive_api import HiveApi
2627

@@ -559,6 +560,9 @@ async def refresh_token(self, token):
559560
"NotAuthorizedException",
560561
"CodeMismatchException",
561562
):
563+
if "Refresh Token has expired" in err.response.get(
564+
"Error", {}).get("Message", ""):
565+
raise HiveRefreshTokenExpired from err
562566
raise HiveInvalid2FACode from err
563567
except botocore.exceptions.EndpointConnectionError as err:
564568
if err.__class__.__name__ == "EndpointConnectionError":

pyhiveapi/apyhiveapi/helper/hive_exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class HiveApiError(Exception):
2525
Exception (object): Exception object to invoke
2626
"""
2727

28+
class HiveRefreshTokenExpired(Exception):
29+
"""Refresh token expired.
30+
31+
Args:
32+
Exception (object): Exception object to invoke
33+
"""
2834

2935
class HiveReauthRequired(Exception):
3036
"""Re-Authentication is required.

0 commit comments

Comments
 (0)