-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token refresh failure reason unclear #747
Comments
@anthony-unmind not sure if this will answer your query about what sort of exception is thrown. The |
Hi @bennycao The full object we receive in our For reference, here is the error we catch in our React Native app:
|
@anthony-unmind the Exception type for reference is https://github.com/auth0/Auth0.Android/blob/main/auth0/src/main/java/com/auth0/android/authentication/AuthenticationException.kt#L114 |
In case anyone facing the same issue:
As a workaround you can use |
Checklist
Description
When calling
SecureCredentialsManager.getCredentials
orCredentialsManager.getCredentials
, an attempt to refresh the token will be made if necessary.If the refresh attempt fails, an error is thrown with the message:
An error occurred while trying to use the Refresh Token to renew the Credentials
(here and here)The issue is that this error is thrown whether the refresh token was also expired (requiring the user to authenticate again) or there was simply a network error.
This makes it impossible for consumer code to decide whether to force the user to logout and reauthenticate, or to at least make a decision about trying again or falling back to offline mode until network conditions have improved.
The Auth0.swift library, by contrast, throws two different errors allowing us to detect general errors verses a user who really should be logged out.
Reproduction
This can be consistently reproduced in an application that relies on the CredentialsManager classes to retrieve (an automatically refresh) tokens.
Test 1 – Genuinely expired user session
try/catch
around any code that attempts to use thegetCredentails
methods.getCredentials
Test 2 – Network error
try/catch
around any code that attempts to use thegetCredentails
methods.getCredentials
The identical error message in both scenarios makes it difficult to know what to do next.
Additional context
For background, we are relying on both libraries (Android and iOS) via the react-native-auth0 package
Auth0.Android version
2.10.2
Android version(s)
The text was updated successfully, but these errors were encountered: