admin管理员组文章数量:1290939
I'm getting incorrect-captcha-sol
error code sometime while using Google reCAPTCHA server side verification api.
I have integrated google recaptcha validation to some of my apis.
To do so, I pass recaptcha token on these api requests from client side and then verify it on server side by following server side validation of recaptcha.
I am getting recaptcha token by executing below code and pass this token to my api request header:
const getRecaptchaToken = () => {
return new Promise((resolve, reject) => {
try {
if (window.grecaptcha && typeof window.grecaptcha.execute === "function") {
grecaptchaExecute(window.grecaptcha.execute);
} else {
window.grecaptcha.ready(async () => {
grecaptchaExecute(window.grecaptcha.execute);
});
}
// grecaptcha execute action
async function grecaptchaExecute(ExecuteAction) {
const captchaToken = await ExecuteAction(
xxxxxx, // my recaptcha site key
{
action: "submit",
}
);
return resolve(captchaToken);
}
} catch (error) {
return reject(error);
}
});
};
Then, on server side I call:
`=${secret_key}&response=${captchaToken}`;
Most of time it is working fine, but some of calls randomly fail and return incorrect-captcha-sol
error code.
Since it's happening randomly, I don't have a good idea when it is occurring and why. Also, I can't find the any details about this error code in the recaptcha documentations.
Any Ideas?
I'm getting incorrect-captcha-sol
error code sometime while using Google reCAPTCHA server side verification api.
I have integrated google recaptcha validation to some of my apis.
To do so, I pass recaptcha token on these api requests from client side and then verify it on server side by following server side validation of recaptcha.
I am getting recaptcha token by executing below code and pass this token to my api request header:
const getRecaptchaToken = () => {
return new Promise((resolve, reject) => {
try {
if (window.grecaptcha && typeof window.grecaptcha.execute === "function") {
grecaptchaExecute(window.grecaptcha.execute);
} else {
window.grecaptcha.ready(async () => {
grecaptchaExecute(window.grecaptcha.execute);
});
}
// grecaptcha execute action
async function grecaptchaExecute(ExecuteAction) {
const captchaToken = await ExecuteAction(
xxxxxx, // my recaptcha site key
{
action: "submit",
}
);
return resolve(captchaToken);
}
} catch (error) {
return reject(error);
}
});
};
Then, on server side I call:
`https://www.google./recaptcha/api/siteverify?secret=${secret_key}&response=${captchaToken}`;
Most of time it is working fine, but some of calls randomly fail and return incorrect-captcha-sol
error code.
Since it's happening randomly, I don't have a good idea when it is occurring and why. Also, I can't find the any details about this error code in the recaptcha documentations.
Any Ideas?
Share Improve this question edited Oct 4, 2021 at 20:57 KyleMit♦ 30.3k72 gold badges510 silver badges700 bronze badges asked Jun 11, 2021 at 11:00 Rahul BansalRahul Bansal 5114 silver badges7 bronze badges 9- 1 Not sure if this is your issue but I got this error when I was using a website that did not have HTTPS. – Greg Commented Aug 9, 2021 at 17:57
- 1 same issue here. I am using HTTPS and still getting it from time to time (less than 1% of requests). – Matanya Commented Oct 5, 2021 at 6:43
- I have the same problem, I read all related topics but didn't find any solution I also couldn't re generate the exception to find out what can we do in these cases. maybe getting a new token from google or something else. did you find any solution for that ? – Danial Jalalnouri Commented Oct 15, 2021 at 12:26
- 1 This link provides info about multiple ways you can get the error. So if you are doing testing several times a day then you might get the error cos their analytics might think you are a bot. Repasting the link so that people who can not see deleted answers get the info. – the Hutt Commented Feb 12, 2022 at 14:13
- 1 [verifyCaptcha] { "success": false, "error-codes": [ "incorrect-captcha-sol" ]} i have experience when handle it, its because whitelist url. – trysetyoutomo Commented Oct 22, 2022 at 16:19
1 Answer
Reset to default 1If it happens randomly and most of time it works fine you can usetry
function so if it receives an incorrect-captcha-sol
it will repeat until the code will work normally. Here is the code:
try {
function Captcha(){
const getRecaptchaToken = () => {
return new Promise((resolve, reject) => {
try {
if (window.grecaptcha && typeof window.grecaptcha.execute === "function") {
grecaptchaExecute(window.grecaptcha.execute);
} else {
window.grecaptcha.ready(async () => {
grecaptchaExecute(window.grecaptcha.execute);
});
}
// grecaptcha execute action
async function grecaptchaExecute(ExecuteAction) {
const captchaToken = await ExecuteAction(
APIKEY,
{
action: "submit",
}
);
return resolve(captchaToken);
}
} catch (error) {
return reject(error);
}
});
};
}
} catch (error) {
Captcha();
}
本文标签: javascriptRecaptcha V3 error incorrectcaptchasol randomlyStack Overflow
版权声明:本文标题:javascript - Recaptcha V3 error incorrect-captcha-sol randomly - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741517015a2382953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论