def deserialize_compact(jwt):
""" Deserialization of a compact representation of a :class:`~jwt.JWE`
:param jwt: The serialized JWT to deserialize.
:rtype: :class:`~jose.JWT`.
:raises: :class:`~jose.Error` if the JWT is malformed
"""
parts = jwt.split(b'.')
# http://tools.ietf.org/html/
# draft-ietf-jose-json-web-encryption-23#section-9
if len(parts) == 3:
token_type = JWS
elif len(parts) == 5:
token_type = JWE
else:
raise Error('Malformed JWT')
return token_type(*parts)
评论列表
文章目录