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')