flask-jwt icon indicating copy to clipboard operation
flask-jwt copied to clipboard

Internal Server Error instead of Bad Request making a wrong request to the auth resource

Open antocaso opened this issue 9 years ago • 2 comments

This is a small issue: making a wrong request to the auth resource, like sending a form data instead of json data, an Internal Server Error occurs. I think that Bad Request may be a better response. I saw your code, _default_auth_request_handler method in details, but i didn't found the problem.

antocaso avatar Mar 11 '16 00:03 antocaso

Server also crashes when no data is posted:

"[...]/flask_jwt/__init__.py", line 115, in _default_auth_request_handler
    username = data.get(current_app.config.get('JWT_AUTH_USERNAME_KEY'), None)
AttributeError: 'NoneType' object has no attribute 'get'

p2 avatar Jul 04 '16 14:07 p2

Sending the "Content-Type: application/json" header with the request solved the problem for me.

ramanraja avatar Nov 16 '20 19:11 ramanraja