React-native-keychain: Android only prompting for biometric the first time

Created on 27 May 2020  路  2Comments  路  Source: oblador/react-native-keychain

Hi

When I run KeychainExample with biometric access control on Android (my OnePlus 5T), the authentication prompt is only shown the first time I try to get the stored values. The following gif shows the flow: Press save => values saved => press load => authenticate => values loaded => delete loaded value from input field => press load => values loaded
KeychainExample

I would expect the authentication prompt to be shown every time the user requests values in the secure storage. I would like to use this for biometric login, but right now I can't use it on Android. It works fine on iOS.

Is this expected behaviour, am I doing something wrong, or is this a bug in the library?

Best regards
Jens

Most helpful comment

@joelnewton I looked into the code, and found out that getGenericPassword also uses accessControl even though I can't find that in the documentation.

So what works for me is:

import * as Keychain from "react-native-keychain"

Keychain.getGenericPassword({
  accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
  authenticationPrompt: {
    title: "Fingerprint",
    cancel: "Cancel",
  },
})

Now I'm prompted for fingerprint on each getGenericPassword().

All 2 comments

I see this too and am on a One Plus 5T like you. If you run the demo via an android emulator I am pretty sure you only get prompted once on that too. I noticed this changed between versions 5.0.1 and 6.0.0 but for me I had issues with Face Id on 5.0.1 so upgraded to 6.0.0 which fixed Face Id but seemed to cause this behaviour.

@joelnewton I looked into the code, and found out that getGenericPassword also uses accessControl even though I can't find that in the documentation.

So what works for me is:

import * as Keychain from "react-native-keychain"

Keychain.getGenericPassword({
  accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
  authenticationPrompt: {
    title: "Fingerprint",
    cancel: "Cancel",
  },
})

Now I'm prompted for fingerprint on each getGenericPassword().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

retailos picture retailos  路  4Comments

binkumar picture binkumar  路  6Comments

donzthefonz picture donzthefonz  路  8Comments

Mike-Van picture Mike-Van  路  3Comments

pani7 picture pani7  路  5Comments