-
Notifications
You must be signed in to change notification settings - Fork 231
Description
Checklist
- The issue can be reproduced in the react-native-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
π± Environment:
- Platform: iOS
- Device: iPhone 16 Pro
π Issue Summary:
We have a hidden Admin/Secret screen in our app to log Auth0 and token info for debugging.
Sometimes after login, we encounter the following:
hasValidCredentials()β returns falsegetCredentials()β returns nothing (no token)Auth0Loadingβ falseAuth0 ErrorβThe stored credentials instance does not contain a refresh token.User TokenandToken Expire Atβ not found
However, once the app is closed and reopened, everything works fine again. All values are populated, and hasValidCredentials() returns true.
This issue is very hard to reproduce and happens very rarely β but it's a critical problem because we rely on hasValidCredentials() to determine login state. If itβs false, we show the login screen β even if the user is already logged in.
π§ͺ What weβre seeing:
Auth0 Valid Credentials: false
Auth0 Error: The stored credentials instance does not contain a refresh token.
Auth0 Loading: false
User Token: Token not found from Auth 0
Token Expire At: Token Expiry not found from Auth 0
This was captured on our in-app admin screen.
πΌ Screenshot:
(Attached separately)
β Expected Behavior:
- If a user has successfully logged in and we haven't cleared the session,
getCredentials()should return the token. hasValidCredentials()should returntrueunless the token is expired or manually cleared.
β Problems:
- We're not using refresh tokens.
- If token is expired, we logout the user.
- But the above state is being returned while
Auth0Loading = false, meaning we are not in a loading state either.
Reproduction
π Reproduction Steps:
- Open the app (fresh install or already logged in).
- At app start, we do the following check to verify login state:
const credentials = await getCredentials(); // supposed to return access token
const isValidUser = await hasValidCredentials(); // expected to return true if user is logged in-
If
isValidUseristrue, we assume the user is logged in and navigate inside the app. -
After that, we log all relevant details in our secret Admin screen:
Auth0 Valid CredentialsAuth0 ErrorAuth0 LoadingUser TokenToken Expire At
-
β Bug:
getCredentials()β returns no tokenhasValidCredentials()β returns falseerrorshows:The stored credentials instance does not contain a refresh token.userobject does contain data like name, email, etc.
-
Now, if the user kills and reopens the app, everything works as expected:
hasValidCredentials()β truegetCredentials()β returns token- No error, all values are populated correctly
This issue occurs rarely and is very difficult to reproduce but impacts user experience significantly when it does.
Additional context
No response
react-native-auth0 version
^4.6.0
React Native version
0.79.2
Expo version
No response
Platform
iOS
Platform version(s)
Latest IOS
