39

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.com/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?

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Rahul Bansal
  • 391
  • 3
  • 7
  • 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 Aug 09 '21 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 Oct 05 '21 at 06: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 Oct 15 '21 at 12:26
  • You are probably not passing in the user's input into the verification routine because you're not getting them from the previous step. – Abdelrhman Arnos Feb 11 '22 at 18:23
  • @AbdelrhmanArnos what do you mean by "user's input"? Recaptcha v3 has no user input. – Derek Feb 11 '22 at 19:05
  • 1
    This [link](https://2captcha.com/blog/google-doesnt-accept-recaptcha-answers) 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 Feb 12 '22 at 14:13
  • 1
    [verifyCaptcha] { "success": false, "error-codes": [ "incorrect-captcha-sol" ]} i have experience when handle it, its because whitelist url. – trysetyoutomo Oct 22 '22 at 16:19

1 Answers1

-3

I have found other forums talking about how it can occur if you validate a token twice. But I haven't been able to test that or confirm that.

Proud of You
  • 65
  • 1
  • 3
  • Your answer does not provide an "answer" or any constructive help. It would have been better as a comment, that said take a look at https://stackoverflow.com/help/how-to-answer for how to improve future answers. – rhys_stubbs Mar 29 '23 at 06:23