GoogleReCaptcha.V3 1.2.0

.NET Core 3.1
There is a newer version of this package available.
See the version list below for details.
Install-Package GoogleReCaptcha.V3 -Version 1.2.0
dotnet add package GoogleReCaptcha.V3 --version 1.2.0
<PackageReference Include="GoogleReCaptcha.V3" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GoogleReCaptcha.V3 --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GoogleReCaptcha.V3, 1.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install GoogleReCaptcha.V3 as a Cake Addin
#addin nuget:?package=GoogleReCaptcha.V3&version=1.2.0

// Install GoogleReCaptcha.V3 as a Cake Tool
#tool nuget:?package=GoogleReCaptcha.V3&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


Library for Google's ReCaptcha v3 backend

Target platform: .NET Core 3.1

When targeting 3.0 use package version 1.1.2


Task<bool> IsCaptchaPassedAsync(string token);
Task<JObject> GetCaptchaResultDataAsync(string token);

Setup guide

Install the package using nuget Update your appsetting.json config file

"googleReCaptcha:SiteKey": "_YOUR_SITE_KEY",
"googleReCaptcha:SecretKey": "YOUR_SECRET_KEY"

You can get your keys here:

Update your middleware

services.AddHttpClient<ICaptchaValidator, GoogleReCaptchaValidator>();

Update your Views

@inject Microsoft.Extensions.Configuration.IConfiguration Configuration

<form asp-action="FormPost">
    <input type="hidden" name="captcha" id="captchaInput" value=""/>

@section Scripts
    <script src="["googleReCaptcha:SiteKey"]"></script>
    grecaptcha.ready(function() {
        grecaptcha.execute('@Configuration["googleReCaptcha:SiteKey"]', { action: 'contact' }).then(function (token) {

Update your controller

inject ICaptchaValidator

public class HomeController : Controller
  private readonly ICaptchaValidator _captchaValidator;
  public HomeController(ICaptchaValidator captchaValidator)
      _captchaValidator = captchaValidator;
  public async Task<IActionResult> FormPost(Model collection, string captcha){
    if (!await _captchaValidator.IsCaptchaPassedAsync(captcha))
        ModelState.AddModelError("captcha","Captcha validation failed");
    return View(collection)

Additional info

You can use following method instead to get all response data

async Task<JObject> GetCaptchaResultDataAsync(string token)


Methods can throw 'HttpRequestException' when connection to the Google's service doesn't work or service doesn't response with HTTP 200


Contact me in case you find any errors or problem via email

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on GoogleReCaptcha.V3:

Package Downloads

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 31,637 5/31/2021
1.3.0 59,192 8/6/2020
1.2.0 7,002 5/28/2020
1.1.2 9,960 11/6/2019
1.1.1 555 11/5/2019
1.1.0 325 11/5/2019
1.0.0 367 11/5/2019

Targeting .NET Core 3.1