from typing import Any


def _jwt_as_string(encoded_jwt: Any) -> str:
    """Ensure that JWT is returned as str."""
    if isinstance(encoded_jwt, str):  # pyjwt >= 2.0.0
        return encoded_jwt
    if isinstance(encoded_jwt, bytes):  # pyjwt < 2.0.0
        return encoded_jwt.decode("utf-8")
    raise ValueError("Unable to read JWT token.")