Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm running the demo code of Python Eve and I'm having troubles with the Auth part. The code I'm running is identical as the repo, except for MongoDB URI in settings.py.
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'
Everything works fine if I put correct credentials in Basic Auth (which are user=admin passwd=secret) but if I don't put Authorization header or correct credentials I don't get a 401, as I would expect, but the application crashes returning 500. This is the traceback.
user=admin
passwd=secret
[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'
I was able to reproduce the issue with just flask. Looks like it has to do with latest werkzeug release. Flask doesn't specify which werkzeug to use and just says anything above 0.14 so you automatically get the latest version (0.15.1 as of today) and on. Version 0.15.0 changes implementation of http exceptions a little, specifically this bit right here introduced the Unauthorized http exception constructor, so it now does not accept that response argument. Before it simply extended HTTPException.
Unauthorized
response
HTTPException
So I suggest to simply pin a spicific version of werkzeug in your project requirements. Anything below version 0.15, say 0.14.1 should work for you.
What else you can do:
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.