mpdavis / python-jose

A JOSE implementation in Python
MIT License
1.54k stars 235 forks source link

"JWTError" is not a known member of module "jose.jwt" #342

Closed tekumara closed 7 months ago

tekumara commented 7 months ago

JWTError is not exported and so vscode errors:

from jose import jwt

...
        try:
            token_header = jwt.get_unverified_header(token)
        except jwt.exceptions.JWTError:
            raise HTTPException(status_code=401, detail="Malformed auth token")

CleanShot 2024-02-12 at 20 47 22@2x

Likewise for jwt.ExpiredSignatureError and jwt.JWTClaimsError

tekumara commented 7 months ago

Resolved by using

import jose.exceptions

...

except jose.exceptions.JWTError: 
     ....