Connecting SDK to API To connect SDK to Oz API, specify the API URL and access token as shown below.
Kotlin
Copy OzLivenessSDK. setApiConnection (OzConnection. fromServiceToken (host, token))
Java
Copy OzLivenessSDK . INSTANCE . setApiConnection (
OzConnection . Companion . fromServiceToken (host , token) ,
null
);
Please note: in your host application, it is recommended that you set the API address on the screen that precedes the liveness check. Setting the API URL initiates a service call to the API, which may cause excessive server load when being done at the application initialization or startup.
Alternatively, you can use the login and password provided by your Oz Forensics account manager:
Kotlin
Copy OzLivenessSDK. setApiConnection (
OzConnection. fromCredentials (host, username, password),
statusListener (
{ token -> /* token */ },
{ ex -> /* error */ }
)
)
Java
Copy OzLivenessSDK . INSTANCE . setApiConnection (
OzConnection . Companion . fromCredentials (host , username , password) ,
new StatusListener < String >() {
@ Override
public void onStatusChanged (@ Nullable String s) {}
@ Override
public void onSuccess ( String token) { /* token */ }
@ Override
public void onError (@ NonNull OzException e) { /* error */ }
}
);
Although, the preferred option is authentication via access token – for security reasons.
For telemetry, set the separate connection as shown below:
Kotlin
Copy OzLivenessSDK. setEventsConnection (
OzConnection. fromCredentials (
"https://tm.ozforensics.com/" ,
"<your_telemetry_user_eg_tm@company.com>" ,
"your_telemetry_password"
)
)
Java
Copy OzLivenessSDK . setEventsConnection (
OzConnection . fromCredentials (
"https://tm.ozforensics.com/" ,
"<your_telemetry_user_eg_tm@company.com>" ,
"your_telemetry_password"
)
);
Clearing authorization:
Kotlin
Copy OzLivenessSDK. setApiConnection ( null )
Java
Copy OzLivenessSDK . INSTANCE . setApiConnection ( null , null );
Other Methods
Check for the presence of the saved Oz API access token:
Kotlin
Copy val isLoggedIn = OzLivenessSDK.isLoggedIn
Java
Copy boolean isLoggedIn = OzLivenessSDK . INSTANCE . isLoggedIn ();
LogOut:
Kotlin
Copy OzLivenessSDK. logout ()
Java
Copy OzLivenessSDK . INSTANCE . logout ();