2323
2424
2525class JWTManager (object ):
26+ """
27+ This object is used to hold the JWT settings and callback functions.
28+ Instances :class:`JWTManager` are *not* bound to specific apps, so
29+ you can create one in the main body of your code and then bind it
30+ to your app in a factory function.
31+ """
32+
2633 def __init__ (self , app = None ):
2734 """
2835 Create the JWTManager instance. You can either pass a flask application
@@ -330,23 +337,7 @@ def claims_verification_failed_loader(self, callback):
330337 self ._claims_verification_failed_callback = callback
331338 return callback
332339
333- def create_refresh_token (self , identity , expires_delta = None ):
334- """
335- Creates a new refresh token
336-
337- :param identity: The identity of this token. This can be any data that is
338- json serializable. It can also be an object, in which case
339- you can use the user_identity_loader to define a function
340- that will be called to pull a json serializable identity
341- out of this object. This is useful so you don't need to
342- query disk twice, once for initially finding the identity
343- in your login endpoint, and once for setting addition data
344- in the JWT via the user_claims_loader
345- :param expires_delta: A datetime.timedelta for how long this token should
346- last before it expires. If this is None, it will
347- use the 'JWT_REFRESH_TOKEN_EXPIRES` config value
348- :return: A new refresh token
349- """
340+ def _create_refresh_token (self , identity , expires_delta = None ):
350341 if expires_delta is None :
351342 expires_delta = config .refresh_expires
352343
@@ -360,25 +351,7 @@ def create_refresh_token(self, identity, expires_delta=None):
360351 )
361352 return refresh_token
362353
363- def create_access_token (self , identity , fresh = False , expires_delta = None ):
364- """
365- Creates a new access token
366-
367- :param identity: The identity of this token. This can be any data that is
368- json serializable. It can also be an object, in which case
369- you can use the user_identity_loader to define a function
370- that will be called to pull a json serializable identity
371- out of this object. This is useful so you don't need to
372- query disk twice, once for initially finding the identity
373- in your login endpoint, and once for setting addition data
374- in the JWT via the user_claims_loader
375- :param fresh: If this token should be marked as fresh, and can thus access
376- fresh_jwt_required protected endpoints. Defaults to False
377- :param expires_delta: A datetime.timedelta for how long this token should
378- last before it expires. If this is None, it will
379- use the 'JWT_ACCESS_TOKEN_EXPIRES` config value
380- :return: A new access token
381- """
354+ def _create_access_token (self , identity , fresh = False , expires_delta = None ):
382355 if expires_delta is None :
383356 expires_delta = config .access_expires
384357
0 commit comments