如何从 URL 获取 Params 到 Authentication 函数? (Python, 烧瓶)

How to get Params from the URL to the Authentification function? (Python, Flask)

我想从 URL 获取参数“organisation”到我的 flask-httpauth 密码验证函数中。到现在为止,我可以将值放入我的正常函数中:

@app.route('/api/<organisation>/admin/todo', methods=['GET'])
@auth_admin.login_required
def get_admin_todo(organisation):
   return jsonify({'organisation': organisation})

但我无法将其放入身份验证功能中:

@auth_admin.get_password
def get_password_admin(username):
   organisation = "" #here I would like to have my organisation value
   password = "my pwd"
   return password

但是我需要这个参数来识别。我想通过他的组织、用户名和密码来识别一个人。 如果有人有任何想法,我将非常高兴。

非常感谢

您可以使用 request.view_args['organisation']:

organisation = request.view_args['organisation']