Skip to content

Golang reCAPTCHA V3 client for verifying requests server side.

License

Notifications You must be signed in to change notification settings

MicahParks/recaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Sponsor this project

 

Packages

No packages published

Languages