pallets-eco / flask-jwt

JWT (JSON Web Tokens) for Flask applications
MIT License
564 stars 178 forks source link

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

Open antocaso opened 8 years ago

antocaso commented 8 years ago

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.

p2 commented 8 years ago

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'
ramanraja commented 3 years ago

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