我正在尝试将 reCAPTCHA enterprise 集成到我的 Flask Web 应用程序的登录页面上。
最初,我将 reCAPTCHA 复选框添加到登录页面,并通过 POST 请求“g-recaptcha-reponse”参数检索令牌,如文档中所述。
但是,在检查令牌是否有效时,我不断收到错误,评估响应对象中显示“MALFORMED”,如下所示......
# main Python code to get the token from the post request
recaptchaToken = request.form.get("g-recaptcha-response")
# response from Google using google-cloud-recaptcha-enterprise Python library
# action name: "projects/<project_id>/assessments/<action_id>" # Note that I hid the project_id and action_id for this question
# event {
# token: "AW-bC4mm022xpjWh2zI7od65_YdX81M6XfBPW5wIJtr8s5XXIzZ6ojfTFl9PjRlDHo601Svqpuyn5E8WhDlcBswXnrPGDbtUHekXcw60deyb8w0wyk1gZA0mJ0Hx9eAhGMI"
# site_key: "6LfpqZcgAAAAAC7RH7qroayHutXeXkpLuKY5iV6a"
# }
# token_properties {
# invalid_reason: MALFORMED
# create_time {
# }
# }
Run Code Online (Sandbox Code Playgroud)
然后我决定寻找其他解决方案,例如将令牌数据附加到表单grecaptcha.enterprise.execute …