The Wayback Machine - https://web.archive.org/web/20221204025118/https://github.com/MicahParks/recaptcha
Skip to content

MicahParks/recaptcha

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Dec 3, 2022
Dec 3, 2022
Dec 3, 2022

Go Report Card Go Reference

recaptcha

The purpose of this package is to provide a simple interface to the Google reCAPTCHA V3 service for verifying requests server side in Golang.

Basic usage

For complete examples, please see the examples directory.

import "github.com/MicahParks/recaptcha"

Step 1: Create the verifier

// Create the verifier.
verifier := recaptcha.NewVerifierV3("mySecret", recaptcha.VerifierV3Options{})

Step 2: Verify the request with Google

// Verify the request with Google.
response, err := verifier.Verify(ctx, frontendToken, remoteAddr)
if err != nil {
    // Handle the error.
}

Step 3: Check the response

// Check the reCAPTCHA response.
err = response.Check(recaptcha.V3ResponseCheckOptions{
    Action:   []string{"submit"},
    Hostname: []string{"example.com"},
    Score:    0.5,
})
if err != nil {
    // Fail the request.
}

Test coverage

Test coverage is currently >90%.

References

About

Golang reCAPTCHA V3 client for verifying requests server side.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages