Persilsoft.Recaptcha.Server
1.0.2
See the version list below for details.
dotnet add package Persilsoft.Recaptcha.Server --version 1.0.2
NuGet\Install-Package Persilsoft.Recaptcha.Server -Version 1.0.2
<PackageReference Include="Persilsoft.Recaptcha.Server" Version="1.0.2" />
paket add Persilsoft.Recaptcha.Server --version 1.0.2
#r "nuget: Persilsoft.Recaptcha.Server, 1.0.2"
// Install Persilsoft.Recaptcha.Server as a Cake Addin #addin nuget:?package=Persilsoft.Recaptcha.Server&version=1.0.2 // Install Persilsoft.Recaptcha.Server as a Cake Tool #tool nuget:?package=Persilsoft.Recaptcha.Server&version=1.0.2
Persilsoft.Recaptcha.Server
It exposes an endpoint to interact with the Google API to validate a token.
Example:
First, you need to register the group of services required by the backend.
using Persilsoft.Recaptcha.Server.Options;
using ServiceCollectionExtensions;
builder.Services.Configure<RecaptchaOptions>(builder.Configuration.GetSection(RecaptchaOptions.SectionKey));
builder.Services.AddRecaptchaService();
In the appsetting.json configuration file, you need to configure the following key:
"Recaptcha": {
"VerifyEndpoint": "https://www.google.com/recaptcha/api/siteverify",
"SecretKey": "xxxxxxxx"
}
Where:
VerifyEndpoint: It is the private key provided by Google to interact with their services.
Once the services are registered, you need to add to the AspNet Core pipeline the Endpoints that interact with the Google API:
using WebApplicationExtensions;
app.UseRecaptchaEndpoints();
Now, you can test the endpoint. If your WebApi has Swagger installed and configured, you'll be able to visualize and execute it.
Verify token
To validate a Recaptcha token, it needs to be validated with the Google API through this endpoint, which has the following JSON structure:
{
"token": "string"
}
Note: To obtain a Recaptcha token, you can refer to the documentation of the package Persilsoft.Recaptcha.Blazor.
If an error occurs while validating the Recaptcha token, a 'VerifyRecaptchaTokenException' exception will be thrown. You can implement a custom exception handler to handle it and format the response appropriately, or you can register the exception handler included in this package.
builder.Services.AddRecaptchaExceptionHandler();
And include it in the pipeline of your AspNet Core application.
app.UseExceptionHandler(builder => { });
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Options (>= 8.0.2)
- Persilsoft.Exceptions (>= 1.0.2)
- Persilsoft.OperationResult (>= 1.0.0)
- Persilsoft.Recaptcha.Shared (>= 1.0.1)
- Swashbuckle.AspNetCore.Annotations (>= 6.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.23 | 164 | 10/16/2024 |
1.0.22 | 126 | 10/4/2024 |
1.0.21 | 89 | 10/4/2024 |
1.0.20 | 99 | 9/1/2024 |
1.0.19 | 111 | 8/28/2024 |
1.0.18 | 83 | 8/28/2024 |
1.0.17 | 110 | 8/18/2024 |
1.0.16 | 107 | 8/18/2024 |
1.0.15 | 133 | 8/12/2024 |
1.0.14 | 207 | 7/20/2024 |
1.0.13 | 154 | 5/25/2024 |
1.0.12 | 88 | 5/21/2024 |
1.0.11 | 212 | 5/5/2024 |
1.0.10 | 178 | 5/4/2024 |
1.0.9 | 96 | 5/1/2024 |
1.0.8 | 95 | 4/28/2024 |
1.0.7 | 97 | 4/27/2024 |
1.0.5 | 94 | 4/27/2024 |
1.0.4 | 102 | 4/27/2024 |
1.0.2 | 113 | 4/21/2024 |
1.0.1 | 109 | 4/21/2024 |
1.0.0 | 110 | 4/21/2024 |