I am working on a React Native mobile app and am using the auth0 SDK (not using the Universal Login pages). I would like to store the credentials using the built-in credential storage that uses Face ID.
I am not sure when I need to call the
requireLocalAuthentication method… Do I need to call it every time before I want to call
- if I call it from inside a useEffect, it does nothing (unexpected)
- if I call it from a button press handler, it prompts the Face ID authentication (as expected)
Am I doing something wrong?
You can call
requireLocalAuthentication after checking if there are any credentials saved.
The way I implemented it on a React Native app is by saving the credentials when the user first logs in successfully via the
saveCredentials method. This method saves the accessToken and all the other props from the Auth0 response on successful authentication.
Once the credentials are saved, when the user has to login again, you can call the
hasCredentials and then
requireLocalAuthentication. This means that the user will be able to login with the stored credentials.
You can find more information here: