recaptcha-verify

Crates.iorecaptcha-verify
lib.rsrecaptcha-verify
version0.2.0
created_at2023-10-13 23:49:12.055937+00
updated_at2025-09-20 00:11:03.639158+00
descriptionRecaptcha verification helper for v2/v3 and enterprise
homepagehttps://github.com/iganev/recaptcha-verify
repositoryhttps://github.com/iganev/recaptcha-verify
max_upload_size
id1002726
size64,083
Ivan Ganev (iganev)

documentation

https://docs.rs/crate/recaptcha-verify/

README

Crates.io API dependency status build and test codecov

recaptcha-verify

Simple, bare-minimum recaptcha verifier helper compatible with v2, v3 and Enterprise.

Quick Start

This library is supposed to be a (near) drop-in replacement for recaptcha-rs. The usage is nearly (but not completely) identical. Here however we use rustls by default, but you could choose from the following features:

  • default-tls - enforces default-tls feature in reqwest
  • native-tls - enforces native-tls feature in reqwest
  • rustls-tls - enabled by default

Another key difference is that this library uses tokio 1 as dev dependency and more recent versions of reqwest and serde.

Changes in 0.1.3

One important change in 0.1.3 is the fact that instead of string we now pass the whole reqwest::Error in RecaptchaError::HttpError. If you previously used the String containing variant, please migrate to using reqwest::Error.

Changes in 0.2.0

Introducing enterprise support. Legacy v2 and v3 verification should continue to work and is backwards compatible.
The verify function is deprecated and should be replaced with verify_v3 to avoid deprecation warnings.
Enterprise support is provided by recaptcha_verify::verify_enterprise and works in a similar way to verify_v3.
For more granular control over the response properties you can use recaptcha_verify::verify_enterprise_detailed.

Example

ReCAPTCHA v2 and v3:

use recaptcha_verify::{RecaptchaError, verify};

let res:Result<(), RecaptchaError> = verify("secret", "token", None).await;

ReCAPTCHA Enterprise:

use recaptcha_verify::{RecaptchaEntError, verify_enterprise};

let res:Result<(), RecaptchaEntError> = verify_enterprise(
        "project",     // your google cloud project identifier
        "api_key",     // your google cloud project API key with access to the recaptcha service
        "site_key",    // your site key setup within the same project
        "token",       // the user challenge token
        Some("login"), // optional action
    )
    .await;

License

This library (recaptcha-verify) is open sourced under the MIT License.

Commit count: 30

cargo fmt