Android - Aadhaar SDK Integration Guide

Aadhaar SDK provides the user to verify Aadhaar status and get relevant information. There are 3 flows listed that can be accomplished - Aadhaar XML through 2 different websites and Digilocker Flow.

Please test the flow by downloading the App APK.

Find a video on the successful flow here: Aadhaar SDK Flow Video.mp4

Find steps below to integrate the Application SDK

  1. Aadhaar SDK has to be integrated with mobile application. The code for the same can be found here: https://github.com/Bureau-Inc/prism-android-sdk-demo-app
  2. In the integration UserId and CredentialId are mandatory fields for integration. CredentialId is unique and provided by Bureau.
  3. UserId is a unique id that is generated per user and can be either the phone number/email/UUID etc that is used to represent every unique user.

Aadhaar Flow

  • User is guided to the UIDAI website to download the paperless e-KYC (Aadhaar .xml) Inputs for "Aadhaar Number" & Captcha are filled by the end user.
  • On continuing, An OTP is received by the end user which is then auto read by the SDK.
  • The SDK only reads the then received OTP message through the screen.
  • Once the details entered are authenticated, the Aadhaar .xml is downloaded in a .zip which is password(share code) protected

Digilocker Flow

  • Users are guided to the Digilocker website to submit their Aadhaar details.
  • Input for "Aadhaar Number" is filled by the end user.
  • On continuing, An OTP is received by the end user which should be entered in the next page.
  • Once the details entered are authenticated, the Aadhaar details are received by bureau backend server.
  • App backend server will make an API call to bureau backend server and fetch the details of the user.

Minimum Requirements

  • minSdkVersion 21
  • AndroidX

Integrations Guide

Add following lines in your root build.gradle

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" 
        //add credentials here
        credentials { username authToken }
        }
    }
}

Add following lines in your module level build.gradle

android {
    ...
    compileOptions {
       sourceCompatibility = 1.8
       targetCompatibility = 1.8
    }
}
dependencies {
    ....
       implementation 'com.github.Bureau-Inc:prism-android-native-sdk:0.53.0'
}

Add the following line in your gradle.properties

authToken=YOUR_AUTH_TOKEN

Common Android Libraries

This library also uses some common android libraries. So if you are not already using them then make sure you add these libraries to your module level build.gradle

  • androidx.appcompat:appcompat:1.2.0

You might need to add the following code to the application tag in Android Manifest file if Mixpanel View Crawler error shows up

<meta-data
            android:name="com.mixpanel.android.MPConfig.DisableViewCrawler"
            android:value="true"/>

Initialise SDK

 PrismEntryPoint prism;
        
        yourinitbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            
            //instantiate your prism 
            prism = PrismInstanceProvider.getInstance(context,activity);
            
            //InitialiseInitialize your prism only once
               prism.initialize(your credentialId,your user id,
                new PrismCallBack(){

                    @Override
                    public void onKYCFinished(ClientAadhaarData aadhaarData, String methodName, Boolean isSuccess,String errorType) {
                               Log.w("Aadhaar Data",aadhaarData.getJsonString.toString())
                    }
                }
               ,your success redirection url,your failure redirection url,a boolean to indicate whether flow should be run on production configuration,
               PrismCustomisation.Builder().build());
               //You can Add customisation to SDK's UI by adding values to PrismCustomisation Builder
                
            //Adding config to prioritisepriortize the flows by which Aadhaar data is to be taken can be added multiple times    
                prism.addConfig(new Config(residentUidaiAadhaarFlow, myAadhaarUidaiFlow,digilockerFlow));
                
                //The above order of methods can be rearranged based on priority
                
           //KYC initiate call
           prism.beginKYCFLow();
            }
        });


Callback

When Aadhaar fetch is successful the callback returns the isSuccess boolean as true and when a failure happens the callback returns the isSuccess boolean as false along with the methodName. By monitoring the method name we can identify which method was used to fetch the Aadhaar details.

new PrismCallBack(){

                    @Override
                    public void onKYCFinished(ClientAadhaarData aadhaarData, String methodName, Boolean isSuccess,String errorType) {
                               if(isSuccess)
                               {
                                    //Write your success logic here
                                    //the object aadhaar data contains the details
                                    //errorType will be empty here
                                    if(methodName==digilockerFlow)
                                    {
                                    //Make the backend API call to get digilocker data
                                    }
                                    else
                                    {
                                    Log.d("Aadhaar Data", aadhaarData.getJsonString.ToString());
                                    Log.d("XML File Uri", aadhaarData.getXmlFileUri().toString());
                                    Log.d("Aadhaar Data", aadhaarData.getZipFileUri().toString());
                                    Log.d("Aadhaar Data", aadhaarData.getShareCode.toString());
                                    }
                               }
                               else
                               {     //Check errorType here
                                      if(errorType== ENDPOINTS_DOWN)
                                        Log.w("Aadhaar Error","No endpoints Available")
                                      else if(errorType== INVOID_AUTH_ERROR)
                                        Log.w("Aadhaar Error","Not authorized")
                                      else if(errorType== DIGILOCKER_ERROR)
                                        Log.w("Aadhaar Error","Digilocker Site error")
                                      else if(errorType== UIDAI_ERROR)
                                        Log.w("Aadhaar Error","UIDAI Site Error")
                                      else if(errorType== INTERNET_ERROR)
                                        Log.w("Aadhaar Error","InternetIntenet Error")
                                      else if(errorType== SDK_ERROR)
                                        Log.w("Aadhaar Error","SDK Error")
                                      else if(errorType== USER_CANCELLED)
                                         Log.w("Aadhaar Error","Cancelled by user")
                                         
                                         
                            
                                     //Write your failure logic here
                                     //You can call another method by reinitializing config and calling beginKYCFlow() as shown below
                                   prism.addConfig(new Config(myAadhaarUidaiFlow,residentUidaiAadhaarFlow,digilockerFlow));
                                   prism.beginKYCFLow();
                               }
                    }
                }

For using the application without digilocker flow, please add the following:

prism.addConfig(Config(residentUidaiAadhaarFlow, myAadhaarUidaiFlow))
prism.beginKYCFLow()

Aadhaar Fetching Methods

Serverside URL's

Serverside code to get the details

curl --location --request GET 'https://api.overwatch.stg.bureau.id/v1/id/UserId/suppliers/offline-aadhaar' \
--header 'Authorization: Basic AuthHeader'

Response

{
    "aadhaarPDFUrl": "https://orch-prd-mb-s3-docum-objects.s3.ap-south-1.amonaws.com/a",
    "aadhaarXMLUrl":"https://orch-prd-mb-s3-docum-objects.s3.ap-south-1.amonaws.com/a",
    "city": "xxxxxi",
    "district": "xxxxx",
    "dob": "DDMMYYYY",
    "gender": "M",
    "merchantId": "org_UlEqmxxxxxX5Y",
    "name": "Gxxxh Pxxxd",
    "pincode": "5xxxx1",
    "requestId": "8828238d-xxxx-4984-xxxx-1f03861bd2ec",
    "state": "Kxxxxxa",
    "statusCode": 200,
    "street": "Nxxxxanumaxxxxxmp",
    "timestamp": 1653951944417
}

SDK Customisations

To customise the theme of the activity use the following theme in your styles.xml file.

<style name="PrismAppTheme">
    ...
    <!--Add Theme Customisation here-->
</style>

<!--To add customisation to toolbar in SDK's activity add the following style-->
<style name="PrismToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
    <item name="android:background">@drawable/invoid_button_bg</item>

</style>
<!--To add customisation to buttons in SDK add the following style-->
<style name="PrismButtonTheme" parent="@android:style/Widget.Button">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:shadowColor">#FF000000</item>
    <item name="android:shadowDx">0</item>
    <item name="android:shadowDy">-1</item>
    <item name="android:shadowRadius">0.2</item>
    <item name="android:background">@color/black</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textStyle">bold</item>
</style>

Error message show to the user can be customised by defining following strings in your strings.xml file

<!--Error message shown in case of OfflineAadhaarHelper.UIDAI_ERROR-->
<string name="invoid_uidai_error">Server down, please try after some time</string>

<!--Error message shown in case of OfflineAadhaarHelper.INVOID_AUTH_ERROR-->
<string name="invoid_auth_error">Not authorized</string>

<!--Error message shown in case of OfflineAadhaarHelper.INTERNET_ERROR-->
<string name="invoid_check_internet_error">Please check your internet connection</string>

Code Customisations

//Add Prism Customisation values to builder and add it to initialise function
new PrismCustomisation.Builder()
.toolBarTitle(YOUR_CUSTOM_TEXT) // adds a custom title to toolbar
.hideToolbar(true) // TO show or hide toolbar in SDK's UI(The default is show)
.build()