flask_jwt_extended.exceptions.NoAuthorizationError: Missing Authorization Header
See original GitHub issuefrom flask import Flask
from flask_jwt_extended import JWTManager, jwt_required
from flask_restful import Api, Resource
app = Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS'] = True
api = Api(app)
jwt = JWTManager(app)
class SomeRoute(Resource):
@jwt_required
def post(self):
return {'message':'success'}, 200
api.add_resource(SomeRoute, '/some_route', endpoint='some_route')
if __name__ == '__main__':
app.run(debug=False)
post the url without token or token expired use flask_restful no problem!
but use flask_restplus it will raise exception
from flask import Flask
from flask_jwt_extended import JWTManager, jwt_required
from flask_restplus import Api, Resource
app = Flask(__name__)
app.config['PROPAGATE_EXCEPTIONS'] = True
api = Api(app)
jwt = JWTManager(app)
class SomeRoute(Resource):
@jwt_required
def post(self):
return {'message':'success'}, 200
api.add_resource(SomeRoute, '/some_route', endpoint='some_route')
if __name__ == '__main__':
app.run(debug=False)
it will return
.......
raise NoAuthorizationError(errors[0])
flask_jwt_extended.exceptions.NoAuthorizationError: Missing Authorization Header
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
flask_jwt_extended exceptions NoAuthorizationError
I find the solution for this above issue. While making the request we have to send the headers in the below format.
Read more >Basic Usage — flask-jwt-extended 4.4.4 documentation
By default, this is done with an authorization header that looks like: Authorization: Bearer <access_token>. We can see this in action using HTTPie....
Read more >flask_jwt_extended.exceptions.NoAuthorizationError Example
def _decode_jwt_from_headers(): # Verify we have the auth header ... None) if not auth_header: raise NoAuthorizationError("Missing Authorization Header") ...
Read more >flask-jwt-extended: Fake Authorization Header during testing ...
Answer a question This is the function I wish to test @jwt_required def get_all_projects(self): # implementation not included here I call ...
Read more >Python get jwt - ProgramCreek.com
"bearer": return None if len(auth) == 1: msg = _("Invalid Authorization header. No credentials provided.") raise exceptions.AuthenticationFailed(msg) elif ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Flask-Restplus has a bug where native flask error handlers don’t work. Hopefully they will fix that eventually, but you should be able to use this as a work around in the mean time: https://github.com/vimalloc/flask-jwt-extended/issues/86#issuecomment-335509456
Also, when I visit the api
http://127.0.0.1:5000/add-a-new-userwhile usingflask_restplus, I get the error asTypeError: ShowUsersForm() takes no arguments. However, I am not passing any parameter to the api. The same route works fine while usingflask_restfulThe resource code is ` class ShowUsersForm(Resource): def get(self): # current_user = UsersModel.find_by_email_address(get_jwt_identity()).name
`
As a result, I am deadlocked between flask_restful and flask_restplus. ANy help upon this will be much appreciated!
`