@@ -555,7 +555,6 @@ def _log_communication(self, res: requests.Response, request_body: bool = True,
555
555
:param res: The response of a request. Also contains the request.
556
556
:param request_body: Option to disable the logging of the request_body.
557
557
:param response_body: Option to disable the logging of the response_body.
558
- :return:
559
558
"""
560
559
561
560
def _log_headers (headers ) -> str :
@@ -944,6 +943,7 @@ def decode_token(self) -> dict:
944
943
"""
945
944
Return a dict with the decoded token payload. This payload contains detailed information about what this token
946
945
has access to.
946
+
947
947
:return: The dict with the decoded token payload.
948
948
"""
949
949
base64_payload : list = self .token .split ('.' )
@@ -1088,6 +1088,7 @@ def __init__(self, token: str = None, refresh_token: str = None, expires_at: int
1088
1088
def get_epoch_millis () -> int :
1089
1089
"""
1090
1090
Get timestamp
1091
+
1091
1092
:return: Current epoch in milliseconds
1092
1093
"""
1093
1094
return int (time .time_ns () / 1000000 )
@@ -1129,10 +1130,14 @@ def parse_token_result(self, res: dict, what: str) -> None:
1129
1130
1130
1131
def expired (self ) -> bool :
1131
1132
"""
1132
- Check token expiration
1133
+ Check token expiration.
1133
1134
1134
- :return: True when the token has been expired *(expires_at - refresh_offset) <= get_epoch_mills()*
1135
+ :return: True when the token has been expired *(expires_at - refresh_offset) <= get_epoch_mills()*. If
1136
+ no *expires_at* is available, always return False since this token would never expire.
1135
1137
"""
1138
+ if self .refresh_time () is None :
1139
+ return False
1140
+
1136
1141
return self .refresh_time () <= self .get_epoch_millis ()
1137
1142
1138
1143
def fresh (self , span : int = 30000 ) -> bool :
@@ -1312,7 +1317,7 @@ def refresh_time(self) -> Optional[int]:
1312
1317
"""
1313
1318
Calculate refresh time.
1314
1319
1315
- :return: Timestamp after which the token becomes invalid.
1320
+ :return: Timestamp after which the token becomes invalid. Returns None if token cannot be refreshed.
1316
1321
"""
1317
1322
return self ._token_info .refresh_time ()
1318
1323
0 commit comments