Native signup with reCaptcha for Android apps

This topic enables you to build native signup with reCaptcha for Android mobile apps using the CyberArk Identity SDK

CyberArk Identity SDK provides a signup feature and Google reCaptcha V2 support and enables mobile apps to build custom registration forms and ease the user onboarding process.

Google reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to keep malicious software from engaging in abusive activities on your website. Meanwhile, legitimate users will be able to log in, make purchases, view pages, or create accounts, and blocks fake users.

If the service suspects that the user interacting with your app might be a bot instead of a human, it serves a CAPTCHA that a human must solve before your app can continue executing.

CyberArk Identity Android SDK will take care of validating the user using reCAPTCHA V2 and then proceed to create an account using CyberArk Identity API’s

Prerequisites

Setup Google reCAPTCHA Configuration:

For using Google reCAPTCHA we have to build two keys: a site key and a site secret key which we have to use for authentication. For creating a new API key navigate to this Google developer's site. And refer to the following diagram to generate the API keys:

Enable reCaptcha for signup in CyberArk Identity:

Enable reCaptcha for signup and optionally add the site key and secret key generated above.

Integrate Signup into the app

Build a native signup UI and integrate the signup with reCaptcha into the mobile app. When the user clicks on signup the user will be created in the CyberArk Identity.

val signupResponseHandler: LiveData<ResponseHandler<SignupCaptchaModel>> =
    CyberArkAuthProvider.signupWithCaptcha(cyberArkAccountBuilder)
        .start(this, signupData, siteKey)

// Verify if there is any active observer, if not then add observer to get API response
if (!signupResponseHandler.hasActiveObservers()) {
    signupResponseHandler.observe(this, {
        when (it.status) {
            ResponseStatus.SUCCESS -> {
                // Hide progress indicator
                progressBar.visibility = View.GONE
                if (it.data!!.success) {
                    showSuccessPopup()
                } else {
                    showErrorPopup(it.data!!.Message)
                }
            }
            ResponseStatus.ERROR -> {
                // Hide progress indicator
                progressBar.visibility = View.GONE
                showErrorPopup("Network Error: Unable to complete signup")
            }
            ResponseStatus.LOADING -> {
                // Show progress indicator
                progressBar.visibility = View.VISIBLE
            }
        }
    })
}