我正在使用Flask / Security进行REST API,我可以从Flask服务器获取身份验证令牌,但是当我需要一种方法来使用令牌进行后续调用时。我正在使用以下代码,但无法将令牌参数输入require_api_token。有任何想法吗?
@app.route("/display")
@require_api_token
def display():
return "displayed!"
def require_api_token(func):
@wraps(func)
def check_token(*args, **kwargs):
print "checking token..."
# Check to see if it's in their session
print session
if 'api_session_token' not in session:
jsonify(success=False, data={'login_required': True}, message='Not Authorized!'), 401
# Otherwise just send them where they wanted to go
return func(*args, **kwargs)
return check_token