Skip to content
Google Recaptcha client for kotlin and java
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
.idea
gradle/wrapper
src/main/kotlin/com/wusatosi/recaptcha
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

kotlin-recaptcha-client

kotlin-recaptcha-client is an kotlin library for server side reCAPTCHA verification, supports both recaptcha v2 and recaptcha v3

This client aims to be as simple as possible

"reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse."

Installation

Via package manager:

Still in the phase of uploading to the maven central, not ready yet

Usage

For v2 client:

import com.wusatosi.recaptcha.v2.RecaptchaV2Client

// val v2Client = RecaptchaClient.createV2("your site key...")
val v2Client = RecaptchaV2Client.create("your site key...")

runBlocking {
  // RecaptchaV2Client.verify is an suspend function
  val result: Boolean = v2Client.verify(token)
  
  // ...
}

For v3 client

import com.wusatosi.recaptcha.v3.RecaptchaV3Client

// val v3Client = RecaptchaClient.createV3("your site key...")
val v3Client = RecaptchaV3Client.create("your site key...")
runBlocking {

  // RecaptchaV3Client.getVerifyScore is an suspend function
  val result: Double = v3Client.getVerifyScore(token)
  
  // ...
}

Universal

import com.wusatosi.recaptcha.RecaptchaClient

val universalClient = RecaptchaClient.createUniversal("your site key...")

runBlocking {

    // RecaptchaClient.verify is an suspend function 
    val result: Boolean = universalClient.verify(token)
    
    // ...
}

Supports using "www.recaptcha.net" instead of "www.google.com" as the API endpoint, for google side more documentation, this can be enable via:

// V2
RecaptchaClient.createV2("your secret key...", true)
// RecaptchaClient.createV2("your secret key...", useRecaptchaDotNetEndPoint = true)

// V3
RecaptchaClient.createV3("your secret key...", true)
// RecaptchaClient.createV3("your secret key...", useRecaptchaDotNetEndPoint = true)

Contributing

Issues, pull requests, are all always welcome

Uses:

License

MIT

You can’t perform that action at this time.