### Programmatically Invoke reCAPTCHA v3 Challenge Source: https://developers.google.com/recaptcha/docs/v3 Use the `grecaptcha.execute` method within the `grecaptcha.ready` function to programmatically invoke the reCAPTCHA challenge. This allows for more control over when the challenge is triggered, such as on a button click. The generated token should then be sent to your backend for verification. ```javascript function onClick(e) { e.preventDefault(); grecaptcha.ready(function() { grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token) { // Add your logic to submit to your backend server here. }); }); } ``` -------------------------------- ### Load reCAPTCHA v3 JavaScript API with Sitekey Source: https://developers.google.com/recaptcha/docs/v3 Load the reCAPTCHA v3 JavaScript API including your sitekey. This is required for programmatic invocation of the challenge. ```html ``` -------------------------------- ### HTML Button for reCAPTCHA v3 Source: https://developers.google.com/recaptcha/docs/v3 Add these attributes to an HTML button to automatically bind the reCAPTCHA v3 challenge. The `data-sitekey` should be replaced with your actual site key, and `data-callback` specifies the function to execute upon successful token generation. ```html ``` -------------------------------- ### Site Verify Response Source: https://developers.google.com/recaptcha/docs/v3 The response from reCAPTCHA v3 is a JSON object containing the success status, score, action, and other relevant details. ```APIDOC ## Site Verify Response Make the request to verify the response token as with reCAPTCHA v2 or Invisible reCAPTCHA. The response is a JSON object: ```json { "success": true|false, // whether this request was a valid reCAPTCHA token for your site "score": number, // the score for this request (0.0 - 1.0) "action": string, // the action name for this request (important to verify) "challenge_ts": timestamp, // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ) "hostname": string, // the hostname of the site where the reCAPTCHA was solved "error-codes": [...] // optional } ``` ``` -------------------------------- ### Site Verify Response Structure Source: https://developers.google.com/recaptcha/docs/v3 This JSON object represents the response received when verifying a reCAPTCHA token. It includes a success status, a risk score, the action name, and other relevant details. ```json { "success": true|false, "score": number, "action": string, "challenge_ts": timestamp, "hostname": string, "error-codes": [] } ``` -------------------------------- ### Load reCAPTCHA v3 JavaScript API Source: https://developers.google.com/recaptcha/docs/v3 Include this script tag in your HTML to load the reCAPTCHA v3 JavaScript API. This is the first step for both automatic and programmatic integration. ```html ``` -------------------------------- ### Define reCAPTCHA v3 Callback Function Source: https://developers.google.com/recaptcha/docs/v3 Define a JavaScript callback function to handle the reCAPTCHA token when it's successfully generated. This function is typically used when automatically binding reCAPTCHA to a button. ```javascript function onSubmit(token) { document.getElementById("demo-form").submit(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.