Skip to content

Commit 66def3b

Browse files
committed
Change WrongTokenError exception message
1 parent 0ac5b25 commit 66def3b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

flask_jwt_extended/view_decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _decode_jwt_from_request(request_type):
208208

209209
# Make sure the type of token we received matches the request type we expect
210210
if decoded_token['type'] != request_type:
211-
raise WrongTokenError('Only {} tokens can access this endpoint'.format(request_type))
211+
raise WrongTokenError('Only {} tokens are allowed'.format(request_type))
212212

213213
# If blacklisting is enabled, see if this token has been revoked
214214
if _token_blacklisted(decoded_token, request_type):

tests/test_view_decorators.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_jwt_required(app):
6767
response = test_client.get(url, headers=make_headers(refresh_token))
6868
json_data = json.loads(response.get_data(as_text=True))
6969
assert response.status_code == 422
70-
assert json_data == {'msg': 'Only access tokens can access this endpoint'}
70+
assert json_data == {'msg': 'Only access tokens are allowed'}
7171

7272

7373
def test_fresh_jwt_required(app):
@@ -110,7 +110,7 @@ def test_fresh_jwt_required(app):
110110
response = test_client.get(url, headers=make_headers(refresh_token))
111111
json_data = json.loads(response.get_data(as_text=True))
112112
assert response.status_code == 422
113-
assert json_data == {'msg': 'Only access tokens can access this endpoint'}
113+
assert json_data == {'msg': 'Only access tokens are allowed'}
114114

115115
# Test with custom response
116116
@jwtM.needs_fresh_token_loader
@@ -135,12 +135,12 @@ def test_refresh_jwt_required(app):
135135
response = test_client.get(url, headers=make_headers(fresh_access_token))
136136
json_data = json.loads(response.get_data(as_text=True))
137137
assert response.status_code == 422
138-
assert json_data == {'msg': 'Only refresh tokens can access this endpoint'}
138+
assert json_data == {'msg': 'Only refresh tokens are allowed'}
139139

140140
response = test_client.get(url, headers=make_headers(access_token))
141141
json_data = json.loads(response.get_data(as_text=True))
142142
assert response.status_code == 422
143-
assert json_data == {'msg': 'Only refresh tokens can access this endpoint'}
143+
assert json_data == {'msg': 'Only refresh tokens are allowed'}
144144

145145
response = test_client.get(url, headers=None)
146146
json_data = json.loads(response.get_data(as_text=True))
@@ -176,7 +176,7 @@ def test_jwt_optional(app):
176176
response = test_client.get(url, headers=make_headers(refresh_token))
177177
json_data = json.loads(response.get_data(as_text=True))
178178
assert response.status_code == 422
179-
assert json_data == {'msg': 'Only access tokens can access this endpoint'}
179+
assert json_data == {'msg': 'Only access tokens are allowed'}
180180

181181
response = test_client.get(url, headers=None)
182182
json_data = json.loads(response.get_data(as_text=True))

0 commit comments

Comments
 (0)