Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Flask-WTF support reCAPTCHA v3?

I have been trying to integrate Google reCAPTCHA v3 to a website through the RecaptchaField provided by Flask-WTF. I know that reCAPTCHA v3 is newly introduced by Google and I am wondering if Flask-WTF support it or not?

To clarify : recaptcha v2 is supported. The question is, if recaptcha v3 is supported as well

like image 432
disooqi Avatar asked Nov 06 '22 22:11

disooqi


1 Answers

please have a look at Flask-Recaptcha which also support V3 from Google: https://github.com/rlid/flask-recaptcha

You can create Recaptcha fields like this:

class Recaptcha3Form(FlaskForm):
    message = TextField(label="Message")
    recaptcha = Recaptcha3Field(action="TestAction", execute_on_load=True)
    submit = SubmitField(label="Submit")

and render it like this:

@app.route("/v3", methods=["GET", "POST"])
def v3():
    form = Recaptcha3Form()
    if form.validate_on_submit():
        form.message.data = "[Success]" + form.message.data
    return render_template("demo.html", form=form)

Please note: I copied the code from the from flask recaptcha documentation

like image 130
ghovat Avatar answered Nov 16 '22 10:11

ghovat