# React Native token storage with local authentication

**URL:** <https://community.auth0.com/t/react-native-token-storage-with-local-authentication/99307>\
**Category:** Get Help\
**Tags:** rotating-refresh-tokens, sessions\
**Created:** [January 30, 2023, 3:54pm UTC](https://community.auth0.com/t/react-native-token-storage-with-local-authentication/99307 "2023-01-30T15:54:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![horiaradu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/horiaradu/32/44136_2.png) [@horiaradu](https://community.auth0.com/u/horiaradu)\
**Post date:** [January 30, 2023, 3:54pm UTC](https://community.auth0.com/t/react-native-token-storage-with-local-authentication/99307/1 "2023-01-30T15:54:03Z")

</div>

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 `getCredentials`?

Also:

- 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?

---

<div class="post-metadata">

**Author:** ![christian.leovido](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/christian.leovido/32/45478_2.png) [@christian.leovido](https://community.auth0.com/u/christian.leovido)\
**Post date:** [March 15, 2023, 3:07pm UTC](https://community.auth0.com/t/react-native-token-storage-with-local-authentication/99307/2 "2023-03-15T15:07:01Z")

</div>

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:  
[https://auth0.github.io/react-native-auth0/CredentialsManager.html](https://auth0.github.io/react-native-auth0/CredentialsManager.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 14, 2024, 10:17pm UTC](https://community.auth0.com/t/react-native-token-storage-with-local-authentication/99307/3 "2024-11-14T22:17:08Z")

</div>

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