Skip to content

auth_utils

is_jwt(token)

Returns whether a given string is a JWT.

Source code in cat/auth/auth_utils.py
def is_jwt(token: str) -> bool:
    """
    Returns whether a given string is a JWT.
    """
    try:
        # Decode the JWT without verification to check its structure
        jwt.decode(token, options={"verify_signature": False})
        return True
    except InvalidTokenError:
        return False