Java SDK
The passkeybase-java package provides a Java client for the PasskeyBase Management API. Manage users, credentials, apps, roles, and enrollment tokens from your Java backend.
Installation
Add the dependency via Maven or Gradle:
pom.xml / build.gradle
<!-- Maven -->
<dependency>
<groupId>com.passkeybase</groupId>
<artifactId>passkeybase-java</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Gradle -->
implementation 'com.passkeybase:passkeybase-java:1.0.0'Quick Start
Initialize the client with your Management API key and tenant domain, then make your first API call.
Main.java
import com.passkeybase.PasskeyBaseClient;
import com.passkeybase.models.User;
import com.passkeybase.models.UserList;
public class Main {
public static void main(String[] args) {
PasskeyBaseClient client = PasskeyBaseClient.builder()
.apiKey("YOUR_MANAGEMENT_API_KEY")
.domain("myapp.auth.ing")
.build();
// List all users
UserList users = client.users().list();
for (User user : users.getData()) {
System.out.printf("%s: %s%n", user.getId(), user.getDisplayName());
}
}
}User Management
Create User
Create a user
import com.passkeybase.params.CreateUserParams;
User user = client.users().create(CreateUserParams.builder()
.externalId("user_123")
.displayName("Jane Doe")
.build());
System.out.printf("Created user: %s%n", user.getId());List Users
List users with pagination
import com.passkeybase.params.ListParams;
// List with pagination
UserList users = client.users().list(ListParams.builder()
.page(1)
.perPage(20)
.build());
for (User user : users.getData()) {
System.out.printf("%s: %s%n", user.getId(), user.getDisplayName());
}
System.out.printf("Total: %d%n", users.getPagination().getTotal());Get User
Get a user by ID
User user = client.users().get("usr_abc123");
System.out.printf("Name: %s%n", user.getDisplayName());
System.out.printf("Passkeys: %d%n", user.getPasskeyCount());
System.out.printf("Last login: %s%n", user.getLastLoginAt());Update User
Update a user
import com.passkeybase.params.UpdateUserParams;
User user = client.users().update("usr_abc123", UpdateUserParams.builder()
.displayName("Jane Smith")
.build());
System.out.printf("Updated: %s%n", user.getDisplayName());Delete User
Deletes a user and all their associated passkeys.
Delete a user
client.users().delete("usr_abc123");Block / Unblock User
Block and unblock
// Block a user (prevents authentication)
client.users().block("usr_abc123");
// Unblock a user
client.users().unblock("usr_abc123");Credential Management
List Credentials
List all passkey credentials for a specific user.
List credentials
import com.passkeybase.models.Credential;
import com.passkeybase.models.CredentialList;
CredentialList credentials = client.credentials().list("usr_abc123");
for (Credential cred : credentials.getData()) {
System.out.printf("%s: %s (%s)%n",
cred.getId(), cred.getDeviceName(), cred.getAuthenticatorType());
}Delete Credential
Revoke a specific passkey credential.
Delete a credential
client.credentials().delete("usr_abc123", "pk_xyz789");Client / App Management
Create App
Create an OAuth app
import com.passkeybase.params.CreateAppParams;
import com.passkeybase.models.App;
App app = client.apps().create(CreateAppParams.builder()
.name("My Mobile App")
.redirectUris(List.of("myapp://callback"))
.build());
System.out.printf("Client ID: %s%n", app.getId());Rotate Secret
Rotate client secret
import com.passkeybase.models.AppSecret;
AppSecret secret = client.apps().rotateSecret("pk_live_abc123");
System.out.printf("New secret: %s%n", secret.getClientSecret());Role Management
Create Role
Create a role
import com.passkeybase.params.CreateRoleParams;
import com.passkeybase.models.Role;
Role role = client.roles().create(CreateRoleParams.builder()
.name("admin")
.description("Administrator role")
.build());
System.out.printf("Role ID: %s%n", role.getId());Assign Users
Assign users to a role
client.roles().assignUser("role_abc123", "usr_abc123");
// List users in a role
UserList users = client.roles().listUsers("role_abc123");
for (User user : users.getData()) {
System.out.printf("%s: %s%n", user.getId(), user.getDisplayName());
}Enrollment Tokens
Generate a one-time token for enrolling a passkey for an existing user. See the Enrollment guide for the full flow.
Create enrollment token
import com.passkeybase.params.CreateEnrollmentTokenParams;
import com.passkeybase.models.EnrollmentToken;
EnrollmentToken token = client.enrollmentTokens().create(
CreateEnrollmentTokenParams.builder()
.externalId("user_123")
.displayName("Jane Doe")
.expiresIn(3600)
.build());
System.out.printf("Token: %s%n", token.getToken());
System.out.printf("Expires: %s%n", token.getExpiresAt());
// Return this token to your frontend for passkey enrollmentError Handling
API errors throw a PasskeyBaseExceptionwith structured error information.
Error handling
import com.passkeybase.PasskeyBaseClient;
import com.passkeybase.exceptions.PasskeyBaseException;
PasskeyBaseClient client = PasskeyBaseClient.builder()
.apiKey("YOUR_MANAGEMENT_API_KEY")
.domain("myapp.auth.ing")
.build();
try {
User user = client.users().get("usr_nonexistent");
} catch (PasskeyBaseException e) {
System.out.printf("Error: %s%n", e.getError()); // "not_found"
System.out.printf("Message: %s%n", e.getMessage()); // "User not found"
System.out.printf("Status: %d%n", e.getStatus()); // 404
}Configuration Options
Configuration
import java.time.Duration;
PasskeyBaseClient client = PasskeyBaseClient.builder()
.apiKey("YOUR_MANAGEMENT_API_KEY") // Required. Management API key.
.domain("myapp.auth.ing") // Required. Your tenant domain.
.timeout(Duration.ofSeconds(30)) // Optional. Request timeout. Default: 10s.
.maxRetries(3) // Optional. Max retry attempts. Default: 2.
.baseUrl("https://custom.url") // Optional. Override API base URL.
.build();| Option | Type | Required | Description |
|---|---|---|---|
apiKey | String | Yes | Your Management API key from the dashboard. |
domain | String | Yes | Your tenant domain (e.g., myapp.auth.ing). |
timeout | Duration | No | Request timeout. Default: 10s. |
maxRetries | int | No | Maximum retry attempts. Default: 2. |
baseUrl | String | No | Override the API base URL. |