Skip to content

Commit b0cb070

Browse files
authored
Merge branch 'main' into separate-clients
2 parents fcb1324 + b07e69b commit b0cb070

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

descope/auth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,17 @@ def _validate_token(
447447
audience=audience,
448448
leeway=self.jwt_validation_leeway,
449449
)
450-
except (ImmatureSignatureError, ExpiredSignatureError):
450+
except (ImmatureSignatureError):
451451
raise AuthException(
452452
400,
453453
ERROR_TYPE_INVALID_TOKEN,
454-
"Received Invalid token times error due to time glitch (between machines) during jwt validation, try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
454+
"Received Invalid token (nbf in future) during jwt validation. Error can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
455+
)
456+
except (ExpiredSignatureError):
457+
raise AuthException(
458+
401,
459+
ERROR_TYPE_INVALID_TOKEN,
460+
"Received expired token (exp in past) during jwt validation. (sometimes can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default)",
455461
)
456462

457463
claims["jwt"] = token

tests/test_descope_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def test_jwt_validation_leeway(self):
824824
self.assertEqual(cm.exception.status_code, 400)
825825
self.assertEqual(
826826
cm.exception.error_message,
827-
"Received Invalid token times error due to time glitch (between machines) during jwt validation, try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
827+
"Received Invalid token (nbf in future) during jwt validation. Error can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
828828
)
829829

830830
def test_select_tenant(self):

0 commit comments

Comments
 (0)