skip to Main Content

I want to integrate adhaar in my flutter application. when the user enters the adhaar number and clicks on send otp then it should validate the given input and do the needful. I verified all the documents in UIDAI Developer portal, but I cannot find a proper solution.

How can I get the API from UIDAI and do the needful? Someone help me with this.

2

Answers


  1. Chosen as BEST ANSWER

    To integrate Aadhaar card verification in your app, we need to establish a partnership with a licensed Authentication Service Agency (ASA) or an e-KYC User Agency (KUA). These entities are authorized by the UIDAI to provide Aadhaar-based authentication services.

    Once we connect with the licensed Authentication Service Agency, we can get API from them and use it in our app. It is to be noted that for every request from the app the agencies might charge a little amount.

    Below is the code for sending and verifying the otp .

    Future<dynamic> sendOtp(String aadhaarNumber) async {
    
    var url = 'https://sandbox.aadhaarkyc.io/api/v1/aadhaar-v2/generate-otp';
    final http.Response response = await http.post(Uri.parse(url),
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
          'Authorization':
              "Bearer YOUR-API"
        },
        body: jsonEncode({'id_number': aadhaarNumber}));
    if (response.statusCode == 200) {
      var dataCard = Aadhaardata.fromJson(json.decode(response.body)["data"]);
      clientID = dataCard.clientId!;
      setState(() {
        showOtpField = true;
      });
      return Aadhaardata.fromJson(json.decode(response.body));
    } else {
      throw Exception('Failed to CREATE event: ${response.body}');
    }
    }
    
    Future<dynamic> validateOtp(String clientId, String otp) async {
    var headers = {
      'Content-Type': 'application/json',
      'Authorization':
          'Bearer YOUR-API'
    };
    var request = http.Request(
        'POST',
        Uri.parse(
            'https://sandbox.aadhaarkyc.io/api/v1/aadhaar-v2/submit-otp'));
    request.body = json.encode({"client_id": clientId, "otp": otp});
    request.headers.addAll(headers);
    
    http.StreamedResponse response = await request.send();
    
    if (response.statusCode == 200) {
      print(await response.stream.bytesToString());
    } else {
      print(response.reasonPhrase);
    }
    return response.statusCode;
    }
    

    This works fine for me .. Contact

    [email protected]

    for getting API support (The mail is obtained from postman website).

    Hope this help someone !!


  2. yes I have also same problem facing from last month…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search