pythonflaskflask-httpauth

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


I would like to get the Parameter "organisation" from the URL into my flask-httpauth password verification function. By now I just can get the value into my normal function:

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

But I can't get it into the Authentification function:

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

But I need this parameter for the identification. I want to identify a person by his organisation, username and his password. I would be very happy if anyone had any ideas.

Thank you very much

snake


Solution

  • You can use request.view_args['organisation']:

    organisation = request.view_args['organisation']