admin管理员组文章数量:1026989
I've been implementing a new log-in page for our website, and one of the requirements is to have recaptcha on two elements in the form (one is for signing up, the other is for getting username/password reminders).
I've managed to get both recaptchas working, and they both function correctly. However when I try to use recaptcha.getResponse() or use the recaptcha.render('callback') method it does not return JSON, despite saying so in the specification. Here's the bit
The response is a JSON object
{
"success": true|false,
"error-codes": [...] // optional
}
I don't get anything remotely like this in the returned data. Instead, it looks Base64 encoded, but fails any decoder that I've tried. It looks like this
03AHJ_VuvWh4kgzEcKC_TBcc_BQjLucuL6g5tKXwYJT...(lots more after this)
Here's my code for doing the recaptchas. It may look messy, but this is just prototyping. Can anyone see if I'm doing something wrong? I think I've followed the spec exactly.
HTML (snipped for brevity)
<script type="text/javascript" src=".js?onload=onloadCallback&render=explicit" async defer></script>
<div id="div_signup_recaptcha"></div>
<div id="div_forgotdetail_recaptcha"></div>
JS/jQuery
var grecaptchaSignup, grecaptchaForgotDetail;
var verifyForgotDetailCallback = function (response) {
console.log(response);
}
var verifySignupCallback = function (response) {
console.log(response);
}
var onloadCallback = function () {
grecaptchaSignup = grecaptcha.render('div_signup_recaptcha', {
'sitekey': 'mykey',
'callback': verifySignupCallback
});
grecaptchaForgotDetail = grecaptcha.render('div_forgotdetail_recaptcha', {
'sitekey': 'mykey',
'callback': verifyForgotDetailCallback
});
};
I've been implementing a new log-in page for our website, and one of the requirements is to have recaptcha on two elements in the form (one is for signing up, the other is for getting username/password reminders).
I've managed to get both recaptchas working, and they both function correctly. However when I try to use recaptcha.getResponse() or use the recaptcha.render('callback') method it does not return JSON, despite saying so in the specification. Here's the bit
The response is a JSON object
{
"success": true|false,
"error-codes": [...] // optional
}
I don't get anything remotely like this in the returned data. Instead, it looks Base64 encoded, but fails any decoder that I've tried. It looks like this
03AHJ_VuvWh4kgzEcKC_TBcc_BQjLucuL6g5tKXwYJT...(lots more after this)
Here's my code for doing the recaptchas. It may look messy, but this is just prototyping. Can anyone see if I'm doing something wrong? I think I've followed the spec exactly.
HTML (snipped for brevity)
<script type="text/javascript" src="https://www.google./recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<div id="div_signup_recaptcha"></div>
<div id="div_forgotdetail_recaptcha"></div>
JS/jQuery
var grecaptchaSignup, grecaptchaForgotDetail;
var verifyForgotDetailCallback = function (response) {
console.log(response);
}
var verifySignupCallback = function (response) {
console.log(response);
}
var onloadCallback = function () {
grecaptchaSignup = grecaptcha.render('div_signup_recaptcha', {
'sitekey': 'mykey',
'callback': verifySignupCallback
});
grecaptchaForgotDetail = grecaptcha.render('div_forgotdetail_recaptcha', {
'sitekey': 'mykey',
'callback': verifyForgotDetailCallback
});
};
Share
Improve this question
asked Nov 20, 2014 at 10:13
BobbyDazzlerBobbyDazzler
1,2039 silver badges24 bronze badges
1 Answer
Reset to default 5Okay, I'm an idiot.
I thought I had read the specification correctly, turns out I missed the essential call to this URL
https://www.google./recaptcha/api/siteverify?secret=your_secret&response=response_string&remoteip=user_ip_address
After I plugged in my private key and the encoded response, I got my JSON object.
Hope this clears up any confusion for other people in my position :(
I've been implementing a new log-in page for our website, and one of the requirements is to have recaptcha on two elements in the form (one is for signing up, the other is for getting username/password reminders).
I've managed to get both recaptchas working, and they both function correctly. However when I try to use recaptcha.getResponse() or use the recaptcha.render('callback') method it does not return JSON, despite saying so in the specification. Here's the bit
The response is a JSON object
{
"success": true|false,
"error-codes": [...] // optional
}
I don't get anything remotely like this in the returned data. Instead, it looks Base64 encoded, but fails any decoder that I've tried. It looks like this
03AHJ_VuvWh4kgzEcKC_TBcc_BQjLucuL6g5tKXwYJT...(lots more after this)
Here's my code for doing the recaptchas. It may look messy, but this is just prototyping. Can anyone see if I'm doing something wrong? I think I've followed the spec exactly.
HTML (snipped for brevity)
<script type="text/javascript" src=".js?onload=onloadCallback&render=explicit" async defer></script>
<div id="div_signup_recaptcha"></div>
<div id="div_forgotdetail_recaptcha"></div>
JS/jQuery
var grecaptchaSignup, grecaptchaForgotDetail;
var verifyForgotDetailCallback = function (response) {
console.log(response);
}
var verifySignupCallback = function (response) {
console.log(response);
}
var onloadCallback = function () {
grecaptchaSignup = grecaptcha.render('div_signup_recaptcha', {
'sitekey': 'mykey',
'callback': verifySignupCallback
});
grecaptchaForgotDetail = grecaptcha.render('div_forgotdetail_recaptcha', {
'sitekey': 'mykey',
'callback': verifyForgotDetailCallback
});
};
I've been implementing a new log-in page for our website, and one of the requirements is to have recaptcha on two elements in the form (one is for signing up, the other is for getting username/password reminders).
I've managed to get both recaptchas working, and they both function correctly. However when I try to use recaptcha.getResponse() or use the recaptcha.render('callback') method it does not return JSON, despite saying so in the specification. Here's the bit
The response is a JSON object
{
"success": true|false,
"error-codes": [...] // optional
}
I don't get anything remotely like this in the returned data. Instead, it looks Base64 encoded, but fails any decoder that I've tried. It looks like this
03AHJ_VuvWh4kgzEcKC_TBcc_BQjLucuL6g5tKXwYJT...(lots more after this)
Here's my code for doing the recaptchas. It may look messy, but this is just prototyping. Can anyone see if I'm doing something wrong? I think I've followed the spec exactly.
HTML (snipped for brevity)
<script type="text/javascript" src="https://www.google./recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<div id="div_signup_recaptcha"></div>
<div id="div_forgotdetail_recaptcha"></div>
JS/jQuery
var grecaptchaSignup, grecaptchaForgotDetail;
var verifyForgotDetailCallback = function (response) {
console.log(response);
}
var verifySignupCallback = function (response) {
console.log(response);
}
var onloadCallback = function () {
grecaptchaSignup = grecaptcha.render('div_signup_recaptcha', {
'sitekey': 'mykey',
'callback': verifySignupCallback
});
grecaptchaForgotDetail = grecaptcha.render('div_forgotdetail_recaptcha', {
'sitekey': 'mykey',
'callback': verifyForgotDetailCallback
});
};
Share
Improve this question
asked Nov 20, 2014 at 10:13
BobbyDazzlerBobbyDazzler
1,2039 silver badges24 bronze badges
1 Answer
Reset to default 5Okay, I'm an idiot.
I thought I had read the specification correctly, turns out I missed the essential call to this URL
https://www.google./recaptcha/api/siteverify?secret=your_secret&response=response_string&remoteip=user_ip_address
After I plugged in my private key and the encoded response, I got my JSON object.
Hope this clears up any confusion for other people in my position :(
本文标签: javascriptGoogle RecaptchaGetResponse not returning JSONStack Overflow
版权声明:本文标题:javascript - Google Recaptcha - GetResponse not returning JSON - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745514488a2153976.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论