Integrate QR code authenticator

This topic enables the android mobile app to integrate a QR code authenticator using the SDK

The CyberArk Identity Android SDK provides highly secure and trusted multi-factor authentication (MFA) to your web app using the QR code authenticator. Use the SDK to integrate the QR code authenticator into the android mobile app and leverage the CyberArk Identity's QR code authentication mechanism.

📘

Prerequisites

  1. 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.

  2. The mobile device has to be enrolled to CyberArk Identity to leverage the QR code authenticator. The Android SDK provides the capability to enroll the device to CyberArk Identity.

How it works?

11661166

Integrate the QR code authenticator in your app

Use CyberArkQRCodeLoginActivity class to implement the flow. The QR code login model is as follows:

/**
 * Start QR Code authenticator Activity
 *
 */
private fun startQRCodeAuthenticator() {
    val intent = Intent(this, CyberArkQRCodeLoginActivity::class.java)
    intent.putExtra("access_token", accessTokenData)
    startForResult.launch(intent)
}

/**
 * Callback to handle QR Code Authenticator result
 */
private val startForResult =
    registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
        if (result.resultCode == Activity.RESULT_OK) {
            // Use key "QR_CODE_AUTH_RESULT" to receive result data
            val data = result.data?.getStringExtra("QR_CODE_AUTH_RESULT")
            // Show QR Code Authenticator result using Toast
            Toast.makeText(
                this,
                data.toString(),
                Toast.LENGTH_LONG
            ).show()
        }
    }