Skip to content

Commit 21a10ff

Browse files
committed
Minor documentation updates
1 parent 624c858 commit 21a10ff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/complex_objects_from_tokens.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
jwt = JWTManager(app)
99

1010

11-
# A user object that we will load our tokens
11+
# A demo user object that we will use in this example
1212
class UserObject:
1313
def __init__(self, username, roles):
1414
self.username = username
1515
self.roles = roles
1616

1717
# An example store of users. In production, this would likely
18-
# be a sqlalchemy instance or something similiar
18+
# be a sqlalchemy instance or something similar
1919
users_to_roles = {
2020
'foo': ['admin'],
2121
'bar': ['peasant'],
@@ -24,7 +24,7 @@ def __init__(self, username, roles):
2424

2525

2626
# This function is called whenever a protected endpoint is accessed.
27-
# This should return a complex object based on the token identity.
27+
# This should return an object based on the token identity.
2828
# This is called after the token is verified, so you can use
2929
# get_jwt_claims() in here if desired. Note that this needs to
3030
# return None if the user could not be loaded for any reason,
@@ -53,14 +53,14 @@ def custom_user_loader_error(identity):
5353
# Create a token for any user, so this can be tested out
5454
@app.route('/login', methods=['POST'])
5555
def login():
56-
username = request.json.get('username', None)
56+
username = request.get_json().get('username', None)
5757
access_token = create_access_token(identity=username)
5858
ret = {'access_token': access_token}
5959
return jsonify(ret), 200
6060

6161

6262
# If the user_loader_callback returns None, this method will
63-
# not get hit, even if the access token is valid. You can
63+
# not be run, even if the access token is valid. You can
6464
# access the loaded user via the ``current_user``` LocalProxy,
6565
# or with the ```get_current_user()``` method
6666
@app.route('/admin-only', methods=['GET'])

0 commit comments

Comments
 (0)