Problems Using `requireAuthentication` with expo-secure-store

Please provide the following:

  1. SDK Version: 45
  2. Platforms: Android/iOS
  3. expo-secure-store

Unlike react-native-keychain, expo-secure-store with requireAuthentication set to true requires authentication both when you SAVE an item and when you retrieve it.

react-native-keychain only needs authentication when you retrieve the item.

Is there a way around this requirement using expo-secure-store? It makes retrieving an old refresh token and then storing a new one very annoying as you have to authenticate twice.

const secureOptions = {'requireAuthentication' : true, 'authenticationPrompt' : 'Authenticate to Verify Your Identity', 'KeychainAccessibilityConstant':SecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY}

const saveSecure = async (value) => {
    try {
        await SecureStore.setItemAsync('SECURE', value, secureOptions)
        return true
    } catch (e) {
        return false
    }
}

const getSecure = async () => {
    try {
        const result = await SecureStore.getItemAsync('SECURE', secureOptions);
        return result
    } catch (e) {
        // this only throws if they reinstall on android
        await SecureStore.deleteItemAsync('SECURE');
        return false
    }
}

async function test() {
    var result = await getSecure() // REQUIRES AUTH
    if (!oldRefreshToken) {
        console.log('error')
    } else {

        // DO SOMETHING WITH RESULT

        await saveSecure('NEW VALUE') // REQUIRES AUTH AGAIN
    }
}

test()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.