How to prevent token expiration in React Native App

Hello,

I have a web app and a mobile app developed in React Native. In the web app, when the token expires after 20 minutes, the user is automatically logged out. However, in the mobile app, I have implemented a PIN screen, and I do not want the user to be required to log in again after 20 minutes.

The app was developed 2 years ago, and the following endpoints were used:

  1. Login: /api/v1/authn
  2. Verify MFA Code: /api/v1/authn/factors/${data.tokenData._embedded.factors[0].id}/verify${data.apiUrl ? data.apiUrl : ''}
  3. Authenticate: await authenticate({ sessionToken: sessionToken })
  4. The user sets the PIN with @haskkor/react-native-pincode

When the user reopens the app, it directly goes to the PIN screen, and there is a validation process:

isAuthenticated().then(async res => {
  if (res.authenticated) {
    navigation.navigate('SplashScreen');
  } else {
    refreshTokens()
      .then(res => {
        navigation.navigate('SplashScreen');
      })
      .catch(e => {
        AsyncStorage.clear().then(res => {
          deleteUserPinCode();
          Alert.alert(
            'Error..!',
            `${t('PinScreen.refresh_token_error')}`,
            [{ text: 'OK', onPress: () => RNRestart.Restart() }],
          );
        });
      });
  }
});

If the user attempts to use the app after 20 minutes, I receive the following error: “Error: The refresh token is invalid or expired.”

How can I configure the React Native app to prevent the token from expiring after 20 minutes?

Thank you for your assistance.

Hi @patriciaferreira

Welcome to the Auth0 Community!

Can you share your tenant’s name with me via DM? I will take a look at the logs and settings.

Thanks
Dawid