1
我需要为我的Flask-RESTful应用使用Autho0。 Auth0有一个example在视图函数上使用装饰器requires_auth
。使用带有Flask-RESTful资源的Autho0装饰器
@app.route('/secured/ping')
@cross_origin(headers=['Content-Type', 'Authorization'])
@requires_auth
def securedPing():
return "All good. You only get this message if you're authenticated"
随着瓶的RESTful我用add_resource
与Resource
类,而不是app.route
以期功能。我如何申请requires_auth
到Version
?
app = Flask(__name__)
API = Api(app)
CORS = CORS(app, resources={r'/api/*': {'origins': '*'}})
API.add_resource(Version, '/api/v1')