Skip to content

Commit 5b9015e

Browse files
committed
Adjust jwt expiry error messages
1 parent ee4949e commit 5b9015e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

descope/auth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,17 @@ def _validate_token(
637637
audience=audience,
638638
leeway=self.jwt_validation_leeway,
639639
)
640-
except (ImmatureSignatureError, ExpiredSignatureError):
640+
except (ImmatureSignatureError):
641641
raise AuthException(
642642
400,
643643
ERROR_TYPE_INVALID_TOKEN,
644-
"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",
644+
"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",
645+
)
646+
except (ExpiredSignatureError):
647+
raise AuthException(
648+
401,
649+
ERROR_TYPE_INVALID_TOKEN,
650+
"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)",
645651
)
646652

647653
claims["jwt"] = token

0 commit comments

Comments
 (0)