from flask_login import login_required
from flask_restful import Resource
@login required
class MyClass(Resource):
#...
In the main file I call the class's methods like:
api.add_resource(MyClass, '/some_url', methods=['GET', 'PUT', 'POST', 'DELETE'])
I think I am using @login_required
the wrong way here, since I get the error
AttributeError: 'function' object has no attribute 'as_view'
So I am assuiming that @login_required
can only be used with functions. Is there a way to incorporate it with a class?
you could give the
class
the decorators it should run :