Skip to content

Commit

Permalink
Add class method to deserialize JWT token
Browse files Browse the repository at this point in the history
One shot api to get a JWT token from a serialized json token

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed May 11, 2022
1 parent 6f0cb25 commit 9f1c0b5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions jwcrypto/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9f1c0b5

Please sign in to comment.