Я использую демо-код в Python Eve и у меня проблемы с аутентификацией.Код, который я запускаю, идентичен репо, за исключением URI MongoDB в settings.py
.
# We want to seamlessy run our API both locally and on Heroku. If running on
# Heroku, sensible DB connection settings are stored in environment variables.
MONGO_URI = 'mongodb://****:****@localhost:27017/admin'
MONGO_DBNAME = 'apitest'
Все работает нормально, если я ввожу правильные учетные данные в Basic Auth (которые user=admin
passwd=secret
), но если я не помещаю заголовок авторизации или правильные учетные данные, я не получаю 401,как и следовало ожидать, но приложение вылетает, возвращая 500. Это трассировка.
[2019-03-28 12:55:32,082] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/methods/common.py", line 317, in rate_limited
return f(*args, **kwargs)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/auth.py", line 79, in decorated
return auth.authenticate()
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/auth.py", line 152, in authenticate
abort(401, description="Please provide proper credentials", response=resp)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/werkzeug/exceptions.py", line 752, in abort
return _aborter(status, *args, **kwargs)
File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/werkzeug/exceptions.py", line 733, in __call__
raise self.mapping[code](*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'response'