The purpose of this package is to provide a simple interface to the Google reCAPTCHA V3 service for verifying requests server side in Golang.
For complete examples, please see the examples
directory.
import "github.com/MicahParks/recaptcha"
// Create the verifier.
verifier := recaptcha.NewVerifierV3("mySecret", recaptcha.VerifierV3Options{})
// Verify the request with Google.
response, err := verifier.Verify(ctx, frontendToken, remoteAddr)
if err != nil {
// Handle the error.
}
// 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 is currently >90%
.