Skip to navigation

Java guide

This page walks through the whole Java SDK in the order you would use it. Each step starts with the shortest code that works, then shows the other ways to write it. Every example compiles on Java 8, so it does not use var.

Download the Java SDK if you have not done so yet.

Requirements

SupportedRecommended
Java8 and newer17 or 21
Librariesjackson-databind 2.x, bcprov-jdk18onjackson-databind 2.22.4, bcprov-jdk18on 1.86
Build toolsMaven, Gradle or plain javac

On Linux and macOS, set your own systemId and storage in the options.

Add the SDK to your project

Put AuthlyX.java in src/main/java/app/authlyx/; its package is app.authlyx. Then add the two libraries. With Maven:

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.22.4</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.86</version>
</dependency>

With Gradle:

implementation "com.fasterxml.jackson.core:jackson-databind:2.22.4"
implementation "org.bouncycastle:bcprov-jdk18on:1.86"

Import the client where you use it:

import app.authlyx.AuthlyX;

Create the client

static final AuthlyX app = new AuthlyX("YOUR_APP_KEY", "1.0.0");

The first value is your app’s AppKey. Find it in the dashboard under your application’s credentials. The second is the version of the program you are building. AuthlyX compares it with the versions you allow in the dashboard, so raise it each time you ship a new build. See Allowed Versions.

Create one client for the whole program and keep it in a static final field or pass it to the classes that need it. Creating it does not connect; nothing is sent until you call init. The client is AutoCloseable, so a console program can also use try-with-resources:

try (AuthlyX app = new AuthlyX("YOUR_APP_KEY", "1.0.0")) {
app.init().join();
}

To change settings, start from the defaults:

static AuthlyX create() {
AuthlyX.Options options = AuthlyX.defaults("YOUR_APP_KEY", "1.0.0");
options.updatePrompt = false;
options.requestBudget = java.time.Duration.ofSeconds(15);
return new AuthlyX(options);
}

All the options are listed in Options.

Three ways to call the SDK

Calls that talk to AuthlyX return a CompletableFuture. You can use it in three ways:

StyleLooks likeWaits?A refused call
join()AuthlyX.Result r = app.init().join();YesThrows CompletionException
thenAcceptapp.init().thenAccept(r -> { ... });NoSkips your code; handle it with exceptionally
Callbackapp.init(r -> { ... });NoArrives as a result with ok() false

“Waits” means the line does not finish until AuthlyX replies. That is fine in a console program or a worker thread, but not on the Swing or JavaFX UI thread, where the window would freeze.

Callbacks exist for init, initialize, licenseLogin, login with a username and password, getVariable and getScriptWithCallback. Callbacks and thenAccept run on the SDK’s background thread, so use SwingUtilities.invokeLater or Platform.runLater before touching UI.

When join() fails it throws a CompletionException with the real AuthlyX.SdkException inside. This small helper unwraps it:

static AuthlyX.SdkException sdkError(Throwable thrown) {
Throwable cause = thrown.getCause() != null ? thrown.getCause() : thrown;
return cause instanceof AuthlyX.SdkException
? (AuthlyX.SdkException) cause
: new AuthlyX.SdkException("CLIENT_ERROR", String.valueOf(cause.getMessage()), "client");
}

Start the SDK

Call init once, before signing in. initialize is the same method with a longer name.

AuthlyX.Result started = app.init().join();
if (!started.ok()) {
System.out.println(started.message());
return;
}
app.init(started -> System.out.println(started.ok() ? "Connected" : started.message()));

init gives you a result even when something is wrong, instead of failing:

Codeok()What happened
APP_INITIALIZEDtrueConnected. Continue to sign-in.
OFFLINE_MODEtrueNo internet, but this PC has saved offline access. See Offline access.
NETWORK_...falseNo internet and nothing saved. Ask the user to try again.
UPDATE_REQUIREDfalseThis version is older than the one in your dashboard. The SDK has already shown an update box.
VERSION_MISMATCHfalseThis version is newer than the dashboard version and is not allowed.
APP_DISABLEDfalseYou paused the app in the dashboard.

Sign in

app.login("YOUR_LICENSE_KEY").join();
app.login("YOUR_USERNAME", "YOUR_PASSWORD").join();
app.deviceLogin().join();

One value is a license key, two values are a username and password, and deviceLogin signs in the current Windows user with no form. licenseLogin("YOUR_LICENSE_KEY") is the same as login with one value. Device login only works for devices you approved first; see Device login.

When AuthlyX refuses a sign-in, join() throws:

try {
app.login(licenseKey).join();
System.out.println("Welcome");
} catch (java.util.concurrent.CompletionException thrown) {
AuthlyX.SdkException error = sdkError(thrown);
System.out.println(error.getMessage());
}

getMessage() is text you can show to the user. error.code is a fixed code for your own checks, such as INVALID_CREDENTIALS, LICENSE_NOT_FOUND, LICENSE_EXPIRED, LICENSE_BANNED, DEVICE_NOT_ALLOWED or DEVICE_LIMIT_REACHED. error.kind says what sort of problem it was:

error.kindMeaningWhat to do
serverAuthlyX answered and said noShow the message
networkNo answer: no internet, firewall, timeoutAsk the user to retry. Do not treat it as a ban.
securityA reply failed verificationDo not unlock anything
storageThe SDK could not read or save its protected filesUsually a permissions problem
cancelledThe request was cancelled or the client was closedNothing

All codes are on the Errors page.

With a callback, no try is needed. For a license key the callback form is licenseLogin:

app.licenseLogin(licenseKey, result ->
System.out.println(result.ok() ? "Welcome" : result.message()));
app.login(username, password, result ->
System.out.println(result.ok() ? "Welcome" : result.message()));

A sign-in method you can reuse:

static String signIn(String licenseKey) {
try {
app.login(licenseKey).join();
return "";
} catch (java.util.concurrent.CompletionException thrown) {
return sdkError(thrown).getMessage();
}
}

It returns an empty string when the sign-in worked and the reason when it did not.

Create an account, change the password, add time

app.registerUser("YOUR_USERNAME", "YOUR_PASSWORD", "YOUR_LICENSE_KEY").join();
app.changePassword("CURRENT_PASSWORD", "NEW_PASSWORD").join();
app.redeemLicense("ANOTHER_LICENSE_KEY").join();

registerUser creates a user account and signs it in. The other two need a signed-in user. All three throw the same way as login.

Read the account

After sign-in, app.userData holds the account details as a Jackson JsonNode. Read each field with path(...), which never returns null:

com.fasterxml.jackson.databind.JsonNode user = app.userData;
String username = user.path("Username").asText("");
String plan = user.path("Plan").asText("");
String expiry = user.path("ExpiryDate").asText("");
int deviceLimit = user.path("DeviceLimit").asInt(0);
FieldExampleNotes
UsernamemayaOnly set for username and password accounts
LicenseKeyMAYA-4R8P-2N6K-9Q3WThe key linked to the account
Emailmaya@example.com
PlanPlus
ExpiryDate2027-04-30T23:59:59.000Znull for lifetime access
SIDS-1-5-21-...The Windows user ID this sign-in is bound to
DeviceLimit3
Country, IpAddressNGWhere the sign-in came from
type, namelicensetype is user, license or device
registeredAt, lastLogin2026-08-12T14:22:10.000Z
features["aim", "esp"]Enabled on/off features
featureValues, metadata{"fov": 90}See Features and metadata

Before sign-in and after sign-out, app.userData is an empty object, so every path(...) returns its fallback. Store app.userData in a local variable at the start of a method so every field you read comes from the same moment.

Methods that return text, numbers and yes/no

static String expiryText() {
com.fasterxml.jackson.databind.JsonNode expiry = app.userData.path("ExpiryDate");
if (!expiry.isTextual())
return "Lifetime";
return expiry.asText().substring(0, 10).replace('-', '/');
}
static long daysLeft() {
com.fasterxml.jackson.databind.JsonNode expiry = app.userData.path("ExpiryDate");
if (!expiry.isTextual())
return 0;
long millis = java.time.Instant.parse(expiry.asText()).toEpochMilli() - System.currentTimeMillis();
return millis <= 0 ? 0 : (millis + 86399999L) / 86400000L;
}
static String buildTopLine() {
String license = app.userData.path("LicenseKey").asText("");
if (license.isEmpty())
return " License: Null";
return " License: " + license + " | Expiry: " + expiryText();
}
static String remainingDays() {
if (app.userData.path("Plan").asText("").isEmpty())
return "N/A";
if (!app.userData.path("ExpiryDate").isTextual())
return "Lifetime";
return daysLeft() + "D";
}
static boolean isPremium() {
return "Premium".equals(app.userData.path("Plan").asText(""));
}

daysLeft() rounds up, so one hour left counts as 1 day.

Features and metadata

Features come from the plan and the account. Some are on/off, some carry a value such as "high" or 90. Metadata is extra information attached to accounts. See Features and metadata.

Read them from the account

These do not contact AuthlyX:

static boolean hasFeature(String name) {
for (com.fasterxml.jackson.databind.JsonNode feature : app.userData.path("features"))
if (name.equals(feature.asText()))
return true;
return false;
}
static String feature(String name, String fallback) {
com.fasterxml.jackson.databind.JsonNode value = app.userData.path("featureValues").path(name);
return value.isMissingNode() || value.isNull() ? fallback : value.asText();
}
static int featureInt(String name, int fallback) {
try {
return (int) Double.parseDouble(feature(name, ""));
} catch (NumberFormatException e) {
return fallback;
}
}
static boolean featureBool(String name, boolean fallback) {
String text = feature(name, "").toLowerCase();
if (text.equals("true") || text.equals("1") || text.equals("yes") || text.equals("on")) return true;
if (text.equals("false") || text.equals("0") || text.equals("no") || text.equals("off")) return false;
return fallback;
}
boolean aim = hasFeature("aim");
int fov = featureInt("fov", 90);
boolean rainbow = featureBool("rainbow", false);
String discord = app.userData.path("metadata").path("discord").asText("");

The values refresh on every heartbeat, so dashboard changes show up without signing in again. For metadata, copy the helpers with "metadata" in place of "featureValues".

Ask AuthlyX directly

AuthlyX.Result all = app.getFeatures().join();
System.out.println(all.data().path("features"));
AuthlyX.Result quality = app.getFeature("quality").join();
System.out.println(quality.data().path("value").asText(""));
AuthlyX.Result aim = app.checkFeature("aim").join();
boolean enabled = aim.data().path("enabled").asBoolean(false);
AuthlyX.Result everything = app.getAllMetadata().join();
AuthlyX.Result discord = app.getMetadata("discord").join();
AuthlyX.Result vip = app.checkMetadata("vip").join();
System.out.println(discord.data().path("value").asText("") + " " + vip.data().path("enabled").asBoolean(false));

getMetadata() with no key returns all metadata, like getAllMetadata().

Save metadata

app.setMetadata("discord", "maya#1234").join();
app.setMetadata("level", 5).join();
app.setMetadata("vip", true).join();

Only keys you allowed for SDK writes in the dashboard can be changed.

Cloud variables

AuthlyX.Result motd = app.getVariable("motd").join();
System.out.println(motd.data().path("value").asText(""));
app.getVariable("motd", result -> {
if (result.ok())
System.out.println(result.data().path("value").asText(""));
});
app.updateVariable("last_build", "1.4.2").join();

See Cloud variables.

Scripts

AuthlyX.Result script = app.getScript("startup", null).join();
String content = script.data().path("content").asText("");
AuthlyX.Result older = app.getScript("startup", 3).join();
app.getScriptWithCallback("startup", result -> {
if (result.ok())
System.out.println(result.data().path("content").asText(""));
});

The second value of getScript is a revision number, or null for the newest. The SDK checks the script’s signature before returning it. It does not run the script. See Scripts.

Logs and webhooks

app.log("Opened the settings page").join();
java.util.Map<String, Object> event = new java.util.HashMap<>();
event.put("item", "skin_42");
event.put("price", 4.99);
app.sendWebhook("purchase.clicked", event).join();

log writes a line to your app’s logs in the dashboard. sendWebhook sends an event to a webhook you set up in the dashboard; the second value can be a Map, a Jackson node or any object Jackson can turn into JSON.

Staying signed in

After sign-in the SDK checks in with AuthlyX in the background (a heartbeat), by default about every 10 minutes, and refreshes features and metadata each time. If you ban, pause or expire the account, the next heartbeat ends the session.

if (!app.hasAccess().join()) {
System.out.println("Please sign in");
}

To be told when the session ends, set the callbacks in the options:

static AuthlyX createWithEvents() {
AuthlyX.Options options = AuthlyX.defaults("YOUR_APP_KEY", "1.0.0");
options.onInvalidated = error -> {
System.out.println("Signed out: " + error.getMessage());
System.exit(0);
};
options.onConnection = state -> System.out.println("Connection: " + state);
return new AuthlyX(options);
}

onConnection receives online, disconnected or untrusted. Both run on a background thread. To check right away, call app.checkSession().join(); app.onResume() does the same and is meant for when your app wakes from sleep. To run the heartbeat yourself, set options.heartbeat = "manual"; and call checkSession() from your own timer. More in Sessions and heartbeats.

Offline access

app.login(licenseKey).join();
app.saveOfflineAccess().join();

Later, without internet, init returns OFFLINE_MODE with ok() true, and the user signs in with the same license key or username and password. The SDK checks them against the saved permit and the sign-in succeeds with the code OFFLINE_ACCESS. app.hasOfflineAccess().join() tells you whether this PC has a valid saved permit. Signing out deletes it. See Offline access.

Updates

When this version is not allowed, init fails with UPDATE_REQUIRED or VERSION_MISMATCH and the SDK shows a message box with the new version, release notes and a button to open your download page. To show your own window, set options.updatePrompt = false; and read the details:

AuthlyX.Result started = app.init().join();
if (started.code().equals("UPDATE_REQUIRED") || started.code().equals("VERSION_MISMATCH")) {
com.fasterxml.jackson.databind.JsonNode update = started.data() == null
? com.fasterxml.jackson.databind.node.MissingNode.getInstance()
: started.data().path("update");
System.out.println(started.message());
System.out.println(update.path("version").asText("") + " " + update.path("url").asText(""));
System.out.println(update.path("notes").asText(""));
}

See Automatic updates.

Sign out and shut down

app.logout().join();
app.close();

logout ends the session, clears userData and deletes saved offline access on this PC. close stops the background threads. A closed client cannot be used again.

Swing and JavaFX

Never call join() on the UI thread. Use a callback or thenAccept, and move back to the UI thread before touching components:

static void onLoginClicked(String licenseKey, javax.swing.JLabel status) {
app.licenseLogin(licenseKey, result ->
javax.swing.SwingUtilities.invokeLater(() ->
status.setText(result.ok() ? "Welcome" : result.message())));
}

In JavaFX, use Platform.runLater in the same place. Reading app.userData is safe from any thread.

Results and errors

AuthlyX.Result has ok() / success(), failed(), code(), message(), requestId() and data(), a Jackson JsonNode. decode(MyType.class) turns data() into your own class.

AuthlyX.SdkException is a RuntimeException with getMessage(), code, kind, status, requestId and data.

Options

Start from AuthlyX.defaults(appKey, version) and change what you need:

FieldDefaultWhat it does
updatePrompttrueShow the built-in update boxes
requestBudget8 secondsHow long one call may take, including retries
heartbeat"server""manual" to run session checks yourself
onInvalidatedNoneCalled when AuthlyX ends the session
onConnectionNoneCalled when the connection state changes
buildHash""This build’s hash, if you use Application hashes
storageProtected files in %LOCALAPPDATA%\AuthlyX\v3Another store, such as new AuthlyX.WindowsProtectedStore(path)
systemIdThe Windows user SIDRequired on Linux and macOS

A complete program

import app.authlyx.AuthlyX;
import java.util.Scanner;
import java.util.concurrent.CompletionException;
public class Main {
public static void main(String[] args) {
try (AuthlyX app = new AuthlyX("YOUR_APP_KEY", "1.0.0");
Scanner input = new Scanner(System.in)) {
AuthlyX.Result started = app.init().join();
if (!started.ok()) {
System.out.println(started.message());
return;
}
System.out.print("License key: ");
String licenseKey = input.nextLine();
try {
app.login(licenseKey).join();
} catch (CompletionException thrown) {
System.out.println(thrown.getCause().getMessage());
return;
}
System.out.println("Plan: " + app.userData.path("Plan").asText(""));
System.out.println("Expires: " + app.userData.path("ExpiryDate").asText("Lifetime"));
System.out.println("Press Enter to sign out");
input.nextLine();
try {
app.logout().join();
} catch (CompletionException ignored) {
}
}
}
}

Each method also has its own page with every language side by side under SDK methods.