Database Verification - 5 Minutes Tutorial - Java SDK
Prerequisites
The following information is required to be able to integrate with Authologic:
- Developer portal credentials,
- API Keys.
Developer Portal Credentials
The developer portal address and credentials were provided during onboarding.
Passwords And API Keys
During the onboarding you have received the API keys:
- API key allowing communication with Authologic.
- The key used to verify the data sent by Authologic by the callback mechanism.
Integration Overview
The entire process is called conversation. The following diagram represents the process logical flow:
- Start of the identity verification process. Your server calls the API method called: POST /api/conversations
- The response returns information about the address to which the user should be redirected
- Your system redirects the user's browser to the above URL
- The user verifies himself
- Authologic redirects the user's browser to a predefined page of your system
- Your server displays the return page
- Authologic calls a callback on your server's side with the result of the verification
One API for multiple online identity verification methods written in Java.
Installation
The installation of the library is as simple as including it as one of the projects dependencies.
We encourage to use the newest version of the library as we are constantly expanding our product offering and the underlying functionalities.
Maven
Include the following dependency in your pom.xml file to use Authologic Java SDK:
<dependency>
<groupId>com.authologic.client</groupId>
<artifactId>authologic-client</artifactId>
<version>0.2.48</version>
</dependency>
Gradle
Include the following dependency in your build.gradle file to use Authologic Java SDK:
implementation("com.authologic.client:authologic-client:0.2.48")
Usage
The following example demonstrate an example on how you can use the Java SDK to interact with the Authologic APIs.
Creating Conversation
To start a new conversation process, which is the main entry point for the identity checking product the following example can be used:
import com.authologic.client.api.*;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Client client = ClientBuilder.builder("username", "password").sandbox().build();
DatabaseVerificationUserInfo dbvUser =
DatabaseVerificationUserInfo.builder()
.name(
DatabaseVerificationName.builder()
.firstName("Jan")
.lastName("Kowalski")
.build())
.info(
DatabaseVerificationInfo.builder()
.birthDate("1973-12-12")
.build())
.build();
Conversation conversation = client.execute(
Requests.
createConversation().
strategy("public:sandbox").
callbackUrl("some_callback_url").
addProduct(
new IdentityProductQueryBuilder(
Arrays.asList(
IdentityQueryField.PERSON_NAME_FIRSTNAME,
IdentityQueryField.PERSON_NAME_LASTNAME
)
)).
addProduct(
ProductQueries.databaseVerification(dbvUser)
)
).get();
System.out.println(conversation.getUrl());
}
}
DatabaseVerificationUserInfo object can contain more fields than shown in the example - besides name
and info it supports ids (nationalId and idCard/driverLicence/passport documents), address and
contact sections. A full example is given below in the Creating the Conversation
section. All fields are optional.Creating the Client Instance
We start by creating the Client instance:
Client client = ClientBuilder.builder("username", "password").sandbox().build();
API credentials can be generated via OmniPanel.
Because the API is secured you need the provided credentials to be able to interact with it.
Once initialized the Client instance may be used to interact with the Authologic API.
Creating the Conversation
Next we can create the conversation and request the first and last name of the person we are
requesting the identification for. For that purpose we use the Requests.createConversation()
using the following code snippet:
Requests.
createConversation().
strategy("public:sandbox").
callbackUrl("some_callback_url").
addProduct(
new IdentityProductQueryBuilder(
Arrays.asList(
IdentityQueryField.PERSON_NAME_FIRSTNAME,
IdentityQueryField.PERSON_NAME_LASTNAME
)
)
).
addProduct(
ProductQueries.databaseVerification(
DatabaseVerificationUserInfo.builder()
.name(
DatabaseVerificationName.builder()
.firstName("Jan")
.middleName("Stanisław")
.lastName("Kowalski")
.fullName("Jan Stanisław Kowalski")
.build())
.ids(
DatabaseVerificationIds.builder()
.nationalId("12345678901")
.idCard(
DatabaseVerificationDocument.builder()
.id("ABC12343")
.issueDate("2020-01-15")
.expiryDate("2030-01-15")
.build())
.build())
.info(
DatabaseVerificationInfo.builder()
.gender(DatabaseVerificationGender.MALE)
.birthDate("1973-12-12")
.birthPlace("Gdansk")
.build())
.address(
DatabaseVerificationAddress.builder()
.street("Cherry Street")
.houseNumber("133")
.city("Warsaw")
.postalCode("00-950")
.countryCode("PL")
.build())
.contact(
DatabaseVerificationContact.builder()
.email("test@email.com")
.phone("123456789")
.build())
.build())
)
We set:
- the strategy
- the callback URL
- the products that we want to use.
The strategy is the information that tells Authologic how to perform the operation.
The field is optional, but you can explicitly provide the information to choose the strategy that
you want to use. In the above example we used the public:sandbox, a strategy which doesn't perform a
real verification, but allows to test the whole flow.
The callback URL is the URL that Authologic will send the user when the process, in our example case the identification process, will be completed. You should set it to match return to your application or use a service like Webhook Site(opens in new tab) if you plan on testing the SDK.
The products that we want to use in this example are the identity product and the database verification product.
For the identity product we use the IdentityProductQueryBuilder class and provide the list of
fields to retrieve:
new IdentityProductQueryBuilder(
Arrays.asList(
IdentityQueryField.PERSON_NAME_FIRSTNAME,
IdentityQueryField.PERSON_NAME_LASTNAME
)
))
For the databaseVerification product we use the ProductQueries.databaseVerification() method.
Calling it without arguments creates a product that runs checks on the identity data collected during
the conversation. You can also pass a DatabaseVerificationUserInfo object to verify the provided
user data against the configured sources - all fields are optional:
addProduct(
ProductQueries.databaseVerification(
DatabaseVerificationUserInfo.builder()
.name(
DatabaseVerificationName.builder()
.firstName("Jan")
.lastName("Kowalski")
.build())
.ids(
DatabaseVerificationIds.builder()
.nationalId("12345678901")
.build())
.info(
DatabaseVerificationInfo.builder()
.birthDate("1973-12-12")
.build())
.address(
DatabaseVerificationAddress.builder()
.city("Warsaw")
.countryCode("PL")
.build())
.contact(
DatabaseVerificationContact.builder()
.email("test@email.com")
.build())
.build())
)
As the final step we print the URL of the created conversation to the standard output to be able to continue the process. If you are trying out the SDK head to the returned link to fill out the data that will be returned as test data for your identity verification test.