88"""
99from flask import jsonify
1010
11+ from flask_jwt_extended .config import config
12+
1113
1214def default_user_claims_callback (userdata ):
1315 """
@@ -37,7 +39,7 @@ def default_expired_token_callback():
3739 By default, if an expired token attempts to access a protected endpoint,
3840 we return a generic error message with a 401 status
3941 """
40- return jsonify ({'msg' : 'Token has expired' }), 401
42+ return jsonify ({config . error_msg_key : 'Token has expired' }), 401
4143
4244
4345def default_invalid_token_callback (error_string ):
@@ -47,7 +49,7 @@ def default_invalid_token_callback(error_string):
4749
4850 :param error_string: String indicating why the token is invalid
4951 """
50- return jsonify ({'msg' : error_string }), 422
52+ return jsonify ({config . error_msg_key : error_string }), 422
5153
5254
5355def default_unauthorized_callback (error_string ):
@@ -57,23 +59,23 @@ def default_unauthorized_callback(error_string):
5759
5860 :param error_string: String indicating why this request is unauthorized
5961 """
60- return jsonify ({'msg' : error_string }), 401
62+ return jsonify ({config . error_msg_key : error_string }), 401
6163
6264
6365def default_needs_fresh_token_callback ():
6466 """
6567 By default, if a non-fresh jwt is used to access a ```fresh_jwt_required```
6668 endpoint, we return a general error message with a 401 status code
6769 """
68- return jsonify ({'msg' : 'Fresh token required' }), 401
70+ return jsonify ({config . error_msg_key : 'Fresh token required' }), 401
6971
7072
7173def default_revoked_token_callback ():
7274 """
7375 By default, if a revoked token is used to access a protected endpoint, we
7476 return a general error message with a 401 status code
7577 """
76- return jsonify ({'msg' : 'Token has been revoked' }), 401
78+ return jsonify ({config . error_msg_key : 'Token has been revoked' }), 401
7779
7880
7981def default_user_loader_error_callback (identity ):
@@ -82,7 +84,7 @@ def default_user_loader_error_callback(identity):
8284 function returns None, we return a general error message with a 401
8385 status code
8486 """
85- return jsonify ({'msg' : "Error loading the user {}" .format (identity )}), 401
87+ return jsonify ({config . error_msg_key : "Error loading the user {}" .format (identity )}), 401
8688
8789
8890def default_claims_verification_callback (user_claims ):
@@ -97,4 +99,4 @@ def default_claims_verification_failed_callback():
9799 By default, if the user claims verification failed, we return a generic
98100 error message with a 400 status code
99101 """
100- return jsonify ({'msg' : 'User claims verification failed' }), 400
102+ return jsonify ({config . error_msg_key : 'User claims verification failed' }), 400
0 commit comments