diff --git a/jwcrypto/jwt.py b/jwcrypto/jwt.py index f7a84c6..749d1f0 100644 --- a/jwcrypto/jwt.py +++ b/jwcrypto/jwt.py @@ -564,3 +564,18 @@ def serialize(self, compact=True): compact representation. """ return self.token.serialize(compact) + + @classmethod + def from_jose_token(cls, token): + """Creates a JWT object from a serialized JWT token. + + :param token: A string with the json or compat representation + of the token. + + :raises InvalidJWEData or InvalidJWSObject: if the raw object is an + invalid JWT token. + """ + + obj = cls() + obj.deserialize(token) + return obj