Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/jwt/exceptions.py: 95%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1class PyJWTError(Exception):
2 """
3 Base class for all exceptions
4 """
6 pass
9class InvalidTokenError(PyJWTError):
10 """Base exception when ``decode()`` fails on a token"""
12 pass
15class DecodeError(InvalidTokenError):
16 """Raised when a token cannot be decoded because it failed validation"""
18 pass
21class InvalidSignatureError(DecodeError):
22 """Raised when a token's signature doesn't match the one provided as part of
23 the token."""
25 pass
28class ExpiredSignatureError(InvalidTokenError):
29 """Raised when a token's ``exp`` claim indicates that it has expired"""
31 pass
34class InvalidAudienceError(InvalidTokenError):
35 """Raised when a token's ``aud`` claim does not match one of the expected
36 audience values"""
38 pass
41class InvalidIssuerError(InvalidTokenError):
42 """Raised when a token's ``iss`` claim does not match the expected issuer"""
44 pass
47class InvalidIssuedAtError(InvalidTokenError):
48 """Raised when a token's ``iat`` claim is non-numeric"""
50 pass
53class ImmatureSignatureError(InvalidTokenError):
54 """Raised when a token's ``nbf`` or ``iat`` claims represent a time in the future"""
56 pass
59class InvalidKeyError(PyJWTError):
60 """Raised when the specified key is not in the proper format"""
62 pass
65class InvalidAlgorithmError(InvalidTokenError):
66 """Raised when the specified algorithm is not recognized by PyJWT"""
68 pass
71class MissingRequiredClaimError(InvalidTokenError):
72 """Raised when a claim that is required to be present is not contained
73 in the claimset"""
75 def __init__(self, claim: str) -> None:
76 self.claim = claim
78 def __str__(self) -> str:
79 return f'Token is missing the "{self.claim}" claim'
82class PyJWKError(PyJWTError):
83 pass
86class MissingCryptographyError(PyJWKError):
87 """Raised if the algorithm requires ``cryptography`` to be installed and it is not available."""
89 pass
92class PyJWKSetError(PyJWTError):
93 pass
96class PyJWKClientError(PyJWTError):
97 pass
100class PyJWKClientConnectionError(PyJWKClientError):
101 pass
104class InvalidSubjectError(InvalidTokenError):
105 """Raised when a token's ``sub`` claim is not a string or doesn't match the expected ``subject``"""
107 pass
110class InvalidJTIError(InvalidTokenError):
111 """Raised when a token's ``jti`` claim is not a string"""
113 pass