Enroll Android device with CyberArk Identity using SDK

This topic enables your android device to enroll with CyberArk Identity and leverage the QR code and mobile push authentication using the SDK

The CyberArk Identity Android SDK is enabled with an enrollment model that verifies an Android device. The enrollment model allows you to build your Android app with the ability to enroll new devices when a QR code or push authentication option is used for the web app login.

πŸ“˜

Prerequisites

An access token should be generated for the user and it should be used to send the API calls for device enrollment. The access token can be generated using the OIDC authorization code with PKCE grant.

The enrollment model is as follows:

val authResponseHandler: LiveData<ResponseHandler<EnrollmentModel>> =
      CyberArkAuthProvider.enroll().start(this, accessTokenData)

// Verify if there is any active observer, if not then add observer to get API response
if (!authResponseHandler.hasActiveObservers()) {
    authResponseHandler.observe(this, {
        when (it.status) {
            ResponseStatus.SUCCESS -> {
                Toast.makeText(
                    this,
                    "Enrolled successfully",
                    Toast.LENGTH_SHORT
                ).show()
            }
            ResponseStatus.ERROR -> {
                Toast.makeText(
                    this,
                    "Error: Unable to Enroll device",
                    Toast.LENGTH_SHORT
                ).show()
            }
            ResponseStatus.LOADING -> {
                // Show progress indicator
            }
        }
    })
}