Skip to content

πŸ› Bug Report: getCredentials() returns empty, hasValidCredentials() false even when user is logged inΒ #1262

@NikulVnnovate57

Description

@NikulVnnovate57

Checklist

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 false
  • getCredentials() β†’ returns nothing (no token)
  • Auth0Loading β†’ false
  • Auth0 Error β†’ The stored credentials instance does not contain a refresh token.
  • User Token and Token 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)

Image


❓ Expected Behavior:

  • If a user has successfully logged in and we haven't cleared the session, getCredentials() should return the token.
  • hasValidCredentials() should return true unless 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:

  1. Open the app (fresh install or already logged in).
  2. 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
  1. If isValidUser is true, we assume the user is logged in and navigate inside the app.

  2. After that, we log all relevant details in our secret Admin screen:

    • Auth0 Valid Credentials
    • Auth0 Error
    • Auth0 Loading
    • User Token
    • Token Expire At
  3. ❗ Bug:

    • getCredentials() β†’ returns no token
    • hasValidCredentials() β†’ returns false
    • error shows: The stored credentials instance does not contain a refresh token.
    • user object does contain data like name, email, etc.
  4. Now, if the user kills and reopens the app, everything works as expected:

    • hasValidCredentials() β†’ true
    • getCredentials() β†’ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    more info neededMore information is required to action or process this issue or PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions