使用BlogEngine集成Recaptcha v2时持续返回'missing-input-secret'错误求助
解决Recaptcha v2返回'missing-input-secret'错误的方案
问题根源
你提供的RecaptchaValidator.cs代码中,构造POST请求表单数据时存在核心错误:
String.Format未使用参数占位符模板,导致三个参数直接拼接成无意义字符串,谷歌无法识别参数键名- 未按照Recaptcha v2要求构造
secret、response、remoteip的键值对格式参数
修复步骤
替换formdata的构造代码:
原错误代码:
var formdata = String.Format( HttpUtility.UrlEncode(this.PrivateKey), HttpUtility.UrlEncode(this.Response), HttpUtility.UrlEncode(this.RemoteIP));
修改为正确的参数格式:
var formdata = string.Format( "secret={0}&response={1}&remoteip={2}", HttpUtility.UrlEncode(this.PrivateKey), HttpUtility.UrlEncode(this.Response), HttpUtility.UrlEncode(this.RemoteIP));
额外验证项
- 确认
PrivateKey是谷歌Recaptcha控制台生成的v2私钥,而非公钥 - 检查
VerifyUrl是否为v2验证端点:https://www.google.com/recaptcha/api/siteverify(v1端点与v2不兼容) - 确保
RemoteIP获取的是用户真实IP,未被代理/反向代理篡改
内容的提问来源于stack exchange,提问作者leof
相关产品推荐
相关产品推荐

