Skip to content

Commit d5491c8

Browse files
added support to retrieve a token given the encoded token
1 parent 8b18943 commit d5491c8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

flask_jwt_extended/blacklist.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from flask_jwt_extended.config import config
77
from flask_jwt_extended.exceptions import RevokedTokenError
8+
from flask_jwt_extended.utils import get_jti
89

910
# TODO make simplekv an optional dependency if blacklist is disabled
1011

@@ -80,13 +81,24 @@ def unrevoke_token(jti):
8081
"""
8182
Revoke a token
8283
83-
:param jti: The jti of the token to revoke
84+
:param jti: The jti of the token to unrevoke
8485
"""
8586
_update_token(jti, revoked=False)
8687

8788

8889
@_verify_blacklist_enabled
89-
def get_stored_token(jti):
90+
def get_stored_token(jti=None, encoded_token=None):
91+
"""
92+
Get the stored token for the passed in jti or encoded_token
93+
94+
:param jti: The jti of the token
95+
:param encoded_token: The encoded JWT string
96+
:return: Python dictionary with the token information
97+
"""
98+
if jti is None and encoded_token is not None:
99+
jti = get_jti(encoded_token)
100+
elif jti is None and encoded_token is None:
101+
raise ValueError('Either jti or encoded_token is required')
90102
return _get_token_from_store(jti)
91103

92104

0 commit comments

Comments
 (0)