Skip to main content

API Reference - Android

Create an SDK Instance#

LoginApi.client().configure(Context context, String clientId, String baseURL)

note

This API must be called before any other APIs. You should call this API within your custom Application's onCreate() method. You can find more information on the process of creating a custom application on Understanding the Android Application Class.

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// clientId example 032690b3-9bc4-4602-87c1-60c1fae782f2
val clientId = "<your client id>"
// baseURL example https://060ce487-b934-43d0-a925-b66e80c7532.native-api.auth.company.id
val baseURL = "<your base url>"
LoginApi.client().configure(this,clientId,baseURL)
// any other configurations
...
...
}
}

API Reference#

registerWithFido2#

Sign up a user for FIDO authentication.

public void registerWithFido2(@NonNull final Activity activity, @NonNull final String username, @Nullable final RegistrationOptions option, @NonNull final RegisterCallback callback)

Where:

RegistrationOptions {
    authorization_token?: string;
}
ParameterTypeRequiredDetails
activityActivitytrueUsing Android biometric api requires the use of FragmentActivity instead of Activity class. This can be done by making sure your calling activity extends the common activity api such as androidx.appcompat.app.AppCompatActivity or androidx.app.fragment.FragmentActivity
usernamestringtrueUsername of the customer to be registered.
optionsRegistrationOptionsoptionalAPI Service token (JWT) signed by your Private Key, as per the API Credential added to the integration. \nRegistrationOptions.buildAuth(token)
callbackRegisterCallbacktrueCallback function to handle returning results (RegisterResponse)

registerWithPassword#

Creates a user account with a password (not recommended). If leveraging this method, users should be migrating to use a FIDO authenticator, then have their password revoked.

public void registerWithPassword(@NonNull final String username, @NonNull final String password, @NonNull final String confirmPassword, @Nullable final RegistrationOptions options, @NonNull final RegisterCallback callback)

ParameterTypeRequiredDetails
usernamestringtrueUsername of the customer to be registered.
passwordstringtruePassword of the customer to be registered.
passwordConfirmationstringtrueIt is best practice to have the customer enter their password twice before creating their profile to prevent typos. If desired, you could only require the end user to enter their password once and pass that password in both fields.
optionsRegistrationOptionsoptionalAPI Service token (JWT) signed by your Private Key, as per the API Credential added to the integration. \nRegistrationOptions.buildAuth(token)
callbackRegisterCallbacktrueCallback function to handle returning results (RegisterResponse)

authenticateWithFido2#

Authenticate a previously registered user through FIDO2.

public void authenticateWithFido2(@NonNull final Activity activity, @NonNull final String username, @Nullable final AuthenticationOptions options, @NonNull final AuthenticateCallback callback)

ParameterTypeRequiredDetails
activityActivitytrueUsing Android biometric api requires the use of FragmentActivity instead of Activity class. This can be done by making sure your calling activity extends the common activity api such as androidx.appcompat.app.AppCompatActivity or androidx.app.fragment.FragmentActivity
usernamestringtrueUsername of the customer to be registered.
optionsAuthenticationOptionsoptionalAPI Service token (JWT) signed by your Private Key, as per the API Credential added to the integration. \nAuthenticationOptions.buildAuth(token)
callbackAuthenticateCallbacktrueCallback function to handle returning results (AuthenticateResponse)

authenticateWithPassword#

Authenticate a previously registered user using username and password.

public void authenticateWithPassword(@NonNull final String username, @NonNull final String password, @Nullable final AuthenticationOptions options, @NonNull final AuthenticateCallback callback)

ParameterTypeRequiredDetails
usernamestringtrueUsername of the customer to be authenticated.
passwordstringtruePassword of the customer to be authenticated.
optionsAuthenticationOptionsoptionalAPI Service token (JWT) signed by your Private Key, as per the API Credential added to the integration. \nAuthenticationOptions.buildAuth(token)
callbackAuthenticateCallbacktrueCallback function to handle returning results (AuthenticateResponse)

confirmTransaction#

Confirm the transaction of a text-based payload using registered Fido2 account.

public void transactionConfirmation(@NonNull final Activity activity, @NonNull final String username, @NonNull final TransactionPayload payload, @Nullable final TransactionOptions options, @NonNull final TransactionConfirmationCallback callback)

ParameterTypeRequiredDetails
activityActivitytrueUsing Android biometric api requires the use of FragmentActivity instead of Activity class. This can be done by making sure your calling activity extends the common activity api such as androidx.appcompat.app.AppCompatActivity or androidx.app.fragment.FragmentActivity
usernamestringtrueUsername of the customer to be authenticated.
payloadTransactionPayloadtrueRequire a client side generated nonce value and a text message to display back to user for confirmation\ne.g. TransactionPayload.buildText("<nonce value here>", message);
optionsAuthenticationOptionsoptionalAPI Service token (JWT) signed by your Private Key, as per the API Credential added to the integration. \nTransactionOptions.buildAuth(token)
callbackTransactionConfirmationCallbacktrueCallback function to handle returning results (TransactionConfirmationResponse)

isLoggedIn#

Check if a given user is currently logged in.

logout#

Deprecated Methods#

The Android SDK previously had the following methods:

  • .register()
  • .login()

The methods have been deprecated, as the type of authenticator is now specified in the register and authenticate methods.