disooqi
disooqi

Reputation: 682

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

Upvotes: 6

Views: 3281

Answers (1)

ghovat
ghovat

Reputation: 1043

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

Upvotes: 1

Related Questions