title: Invalid input response and secret when verifying google reCaptcha
body: <p>I am really struggling to get a successful response when doing a post request to the google recaptcha api. I am receiving the following response:</p>
  
  <pre><code>{
    "success": false,
    "error-codes": [
      "invalid-input-response",
      "invalid-input-secret"
    ]
  }
  </code></pre>
  
  <p>I had a look at <a href="https://stackoverflow.com/questions/52416002/recaptcha-error-codes-missing-input-response-missing-input-secret-when-v">reCAPTCHA - error-codes: 'missing-input-response', 'missing-input-secret' when verifying user's response (missing details on POST)</a> and followed the answer as closely as possible but with no success.</p>
  
  <p>Here is my file below: </p>
  
  <pre><code>var request = require('request');
  
  module.exports = {
    verifyCaptcha: function(req, res) {
  
      var secret = 'SECRET_KEY';
      var response = JSON.stringify(req.body.response);
      request({
          url: 'https://www.google.com/recaptcha/api/siteverify',
          method: 'POST',
          headers: { "Content-Type": "application/x-www-form-urlencoded" },
          body: `secret=${secret}&amp;response=${response}`,
      }, function (err, response, body) {
          if (err) {
              res.status(500).send({
                  error: "Could not verify captcha"
              });
          } else {
              res.status(200).send({
                  message: body
              });
          }
      });
    },
  }
  </code></pre>
  
  <p>If anyone has a solution to this problem please let me know!</p>