title: How to implement recaptcha v3 in ColdFusion?
body: <p>Making first call to Google for getting the token from <code>contact_m.cfm</code> and submitting it to the same page for verifying it. Using ColdFusion call next to protect secret key. Calling the function remotely to invoke the ColdFusion function. Doing this as realized ColdFusion renders and do not look for changes.</p>
  
  <pre><code>grecaptcha.ready(function() {
      grecaptcha.execute('token', {action: 'contact'}).then(function(token) {
      $.ajax(
          {
          url: "./contact_m.cfm", 
          type: "post", 
          contentType: "application/json",
          data: JSON.stringify( {googleToken: token} ),
          success: function(result){
              $.get('./contact_m.cfm?func=googleVerification', function (r) {
              });
          }
      });
  });
  });
  </code></pre>
  
  <p>Verifying the token with Google:</p>
  
  <pre><code>&lt;cffunction access="public" name="googleVerification"&gt; 
      &lt;cfargument required="true" type="any" name="myArgument"&gt; 
      &lt;cfset requestBody = toString( getHttpRequestData().content ) /&gt;
  
      &lt;cfif  isJSON( requestBody )&gt;
          &lt;cfset token = DeserializeJSON(#requestBody#)/&gt;
  
          &lt;cfhttp method="post" url="https://www.google.com/recaptcha/api/siteverify" result="googleResult"&gt;
              &lt;cfhttpparam name="secret" type="formField" value="6Lf9IrAUAAAAAOhEdBvk1ZyIKX6eUqS06GaSXG_F"&gt;
              &lt;cfhttpparam name="response" type="formField" value="#token.googleToken#"&gt;
          &lt;/cfhttp&gt;
  
          &lt;cfset googleResponse = DeserializeJSON(#googleResult.FileContent#)/&gt;
          &lt;cfset isHuman = #googleResponse.success#/&gt;
      &lt;/cfif&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>And JavaScript function to check if Google success or fail:</p>
  
  <pre><code>&lt;script&gt;
          function validateHuman(){
          &lt;cfoutput&gt;
              var #toScript(isHuman, "isHuman")#;
          &lt;/cfoutput&gt; 
          console.log(isHuman);
  
          if (isHuman == 'YES') {
              return true;
          } else return false;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>And allow user to submit the form if Google verifies:</p>
  
  <pre><code>&lt;form id="form3" action="contact_m.cfm" method="post" onsubmit="return validateHuman();"&gt;
  </code></pre>
  
  <p>I get error which says: <code>isHuman</code> is undefined.
  Related Question: <a href="https://stackoverflow.com/questions/54431330/recaptcha-v3-with-coldfusion">reCaptcha v3 with ColdFusion</a></p>