Fingerprint Authentication Login Page Touch Id / Client Id Ionic Android/IOS


#1

Hi, guys! I’m new on Ionic 3.I try to use fingerprint on Login page.On sign up user will put fingerprint as an option, what parameters should i send to backend? I try to find something like fingerprint model (biometric fingerprint), and every time on login to check the current model fingerprint with model from backend, but without any luck. On ionic i found plugin fingerprintAio, I use this plugin to initiate fingerprint authentication, I check fingerprint using fingerprint scanner on my phone, but it send a client Id (I don’t know where I can find or generate, and after sign up, on login I don’t know how to take that client ID).
Any suggestions are welcome. Thanks.

SIGN UP:

async fingerprintFunction{
try{
await this.platform.ready();
const keyTest = await this.fingerPrintAIO.isAvailable()
let fingerOption= {
clientId: this.device.uuid // I try to use device.uuid, but I’m not sure that it is a secret parameter
clientSecret: ‘password’,
disableBackup:true,
}
if(keyTest){
this.fingerPrintAIO.show(fingerOption)
.then((result: any) => {
this.nativeStorage.setItem(this.device.uuid,{password:“Pass”}).then(
data=>{
console.log( data);
}
)
console.log(result)
})
.catch((error: any) =>
console.log(error));

  }
}
catch(error){
  console.log(error)
}

}

LOGIN:
async openFingerprintAndroid(){
let password;
try{
await this.platform.ready();
await this.androidFingerprintAuth.isAvailable()
.then((result)=> {
if(result.isAvailable){
this.nativeStorage.getItem(this.device.uuid).then(
data=>{
password = data.password;
}
).catch(error=>{
console.log(error)
})

                    this.androidFingerprintAuth.encrypt({ clientId: this.device.uuid, password:password})
                      .then(result => {
                        console.log("Result", result)
                        
                        if (result.withFingerprint) {
                            console.log('Successfully encrypted credentials.');
                            console.log('Encrypted credentials: ' + result.token);
                        } else if (result.withBackup) {
                          console.log('Successfully authenticated with backup password!');
                        } else console.log('Didn\'t authenticate!');
                      })
                      .catch(error => {
                        if (error === this.androidFingerprintAuth.ERRORS.FINGERPRINT_CANCELLED) {
                          console.log('Fingerprint authentication cancelled');
                        } else console.error(error)
                      });

                  } else {
                    // fingerprint auth isn't available
                  }
                })
                .catch(error => console.error(error));
    }
    catch(e){
      console.log(e);
    }

}