Java / Kotlin

The following tutorial will show you how to integrate Trustcaptcha into Java or Kotlin.

Preparation

The following preparations should be made before you start implementing Trustcaptcha in your Java or Kotlin backend.

Requirements

  • An account with Trustcaptcha and an existing CAPTCHA.
  • A backend with Java or Kotlin in which Trustcaptcha is to be integrated.

Knowledge (recommended)

  • Basic knowledge in Java and/or Kotlin.
  • Understanding of the basic functionality of Trustcaptcha as well as the backend process.

Add Dependency

To use the Trustcaptcha library, you must first insert the corresponding dependencies into your project.

Maven

Insert the following dependency into your pom.xml file to use Trustcaptcha with Maven.

Gradle

Add the following dependency to your build.gradle or build.gradle.kts file to use Trustcaptcha with Gradle-Groovy or Gradle-Kotlin.

Use Library

Nachstehend erfahren Sie, wie Sie die Bibliothek verwenden können.

Fetch Result

You can retrieve the verification result using the getVerificationResult() method of the CaptchaManager class from our servers. For this, you must provide your secret-keyue and the verification token.

Use Result

Once you have successfully retrieved the verification result, you can plan your next steps based on it. A concrete overview of all the information contained in the verification result and their respective meanings can be found in The Backend.

Example with Spring

The following example shows a possible implementation with the Spring Boot framework. With a POST request to /api/example, the verification token is transmitted within the RequestBody verificationResult. Subsequently, the result is retrieved from the server. If the verification has not been passed or the bot score is above 0.5, a warning will be given as an example. Finally, the entire result is returned to the client.
The entire example including source code can be found on Github.