title: reCAPTCHA - error-codes: 'missing-input-response', 'missing-input-secret' when verifying user's response (missing details on POST)
body: <p>I am setting an <a href="https://developers.google.com/recaptcha/docs/invisible" rel="noreferrer">invisible reCAPTCHA</a> in my web application and having trouble verifying the user's response. (even though I am passing the correct POST parameters)</p>
  
  <p>I am programmatically invoking the challenge by calling <code>grecaptcha.execute();</code> on the client-side. And submitting the form afterwards (<code>registrationForm.submit();</code>) using the recaptcha callback:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="g-recaptcha"
    data-sitekey="SITE_KEY"
    data-callback="onSubmit"
    data-size="invisible"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Now after reading <a href="https://developers.google.com/recaptcha/docs/verify" rel="noreferrer"><em>"Verifying the user's response"</em></a> documentation, I figured that the response token is passed as a POST parameter to <code>g-recaptcha-response</code>:</p>
  
  <blockquote>
    <p>For web users, you can get the user’s response token in one of three ways:</p>
    
    <ul>
    <li>g-recaptcha-response POST parameter when the user submits the form on your site</li>
    <li>...</li>
    </ul>
  </blockquote>
  
  <p>So I am using <a href="https://fetch.spec.whatwg.org/" rel="noreferrer">Fetch</a> to create a POST request on the server side to the <a href="https://developers.google.com/recaptcha/docs/verify#api-request" rel="noreferrer">verification endpoint</a> with the required body data:</p>
  
  <pre class="lang-js prettyprint-override"><code>verify(req, res, next) {
    const VERIFY_URL = "https://www.google.com/recaptcha/api/siteverify";
  
    return fetch(VERIFY_URL, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        secret:   process.env.RECAP_INVIS_SECRET_KEY,
        response: req.body['g-recaptcha-response'],
      }),
    })
    .then(response =&gt; response.json())
    .then(data =&gt; {
      res.locals.recaptcha = data;
      return next();
    });
  }
  </code></pre>
  
  <p>But I keep getting the following response:</p>
  
  <blockquote>
    <p>{
     success:        false,
     error-codes: [ 'missing-input-response', 'missing-input-secret' ]
    }</p>
  </blockquote>
  
  <p>Even though I am passing the response and secret as JSON data in the POST body.</p>
  
  <p>Am I doing something wrong? Regards.</p>