Verifying the user's response

This page explains how to verify a user's response to a reCAPTCHA challenge from your application's backend. When a reCAPTCHA is solved by end user, a new field (g-recaptcha-response) will be populated in HTML. You can verify the user’s response in one of three ways:

  • g-recaptcha-response POST parameter when the user submits the form on your site
  • grecaptcha.getResponse(opt_widget_id) after the user completes the CAPTCHA challenge
  • As a string argument to your callback function if data-callback is specified in either the g-recaptcha tag attribute or the callback parameter in the grecaptcha.render method

If your website performs server side validation using an AJAX request, you should only verify the user’s reCAPTCHA response token (g-recaptcha-response) once. If a verify attempt has been made with a particular token, it cannot be used again. You will need to call grecaptcha.reset() to ask the end user to verify with reCAPTCHA again.

API Request

URL: https://www.google.com/recaptcha/api/siteverify


POST Parameter Description
secret Required. The shared key between your site and ReCAPTCHA.
response Required. The user response token provided by the reCAPTCHA to the user and provided to your site on.
remoteip Optional. The user's IP address.

API Response

The response is a JSON object:

  "success": true|false,
  "error-codes": [...]   // optional

Error code reference

Error code Description
missing-input-secret The secret parameter is missing.
invalid-input-secret The secret parameter is invalid or malformed.
missing-input-response The response parameter is missing.
invalid-input-response The response parameter is invalid or malformed.