Skip to content

osslabz/turnstile-siteverify-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turnstyle Siteverity Client

GitHub GitHub Workflow Status Maven Central

Cloudflare Turnstile Client

This is a Java client library for the Cloudflare Turnstile Siteverify API. It provides a simple and efficient way to verify Turnstile tokens in your Java applications.

Features

  • Easy-to-use API for verifying Turnstile tokens
  • Built with OkHttp for efficient HTTP requests
  • Uses Jackson for JSON parsing

Installation

To use this library in your project, add the following dependency to your pom.xml file:

<dependency>
    <groupId>net.osslabz</groupId>
    <artifactId>turnstile-siteverify-client</artifactId>
    <version>0.4.0</version>
</dependency>

Usage

Here's a simple example of how to use the Cloudflare Turnstile Client:

import com.example.cloudflare.turnstile.TurnstileClient;
import com.example.cloudflare.turnstile.TurnstileResponse;

public class Example {
    public static void main(String[] args) {
        String secretKey = "your_secret_key_here";
        TurnstileClient client = new TurnstileClient(secretKey);

        try {
            TurnstileResponse response = client.verify("turnstile_response_token");
            if (response.isSuccess()) {
                System.out.println("Verification successful!");
            } else {
                System.out.println("Verification failed: " + response.getErrorCodes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Configuration

You can customize the OkHttpClient and ObjectMapper used by the TurnstileClient by using the appropriate constructor:

OkHttpClient customHttpClient = new OkHttpClient.Builder()
    .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
    .build();
ObjectMapper customObjectMapper = new ObjectMapper();

TurnstileClient client = new TurnstileClient(secretKey, customHttpClient, customObjectMapper);

Contributions are welcome! Please feel free to submit a Pull Request.

License

About

This is a Java client library for the Cloudflare Turnstile Siteverify API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages