Skip to content

Provide a way to distinguish recoverable and unrecoverable errors #748

@ezorrio

Description

@ezorrio

Checklist

  • 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.

Describe the problem you'd like to have solved

I'm trying to figure out how to build a robust error-handling around token refreshes.
What I've noticed is that CredentialsManagerException provides 3 bool flags, isTokenRenewFailed, isNoCredentialsFound.

isTokenRenewFailed covers all cases in which refresh has failed: it can be a network problem (recoverable, we can try later w/o logging the user out) or unrecoverable (invalid refresh token). Could be more cases.

There is no way to precisely what went wrong

Describe the ideal solution

Ideally, I would like to have a flag "isRecoverable" - so that I know I can still try to fetch the token, else: drop the storage and logout.

Alternatives and current workarounds

We can parse string with error and see what happened. The problem here is the output is indeterministic, it might be many more different errors like this depending on device, OS version, system language and etc.

Across devices I've tested mocking different scenarios:

Case 1: No internet
iOS: Error: RENEW_FAILED: The credentials renewal failed. CAUSE: Unable to complete the operation. CAUSE: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x600003e13ae0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 0ms using unknown from cache, _NSURLErrorNWPathKey=unsatisfied (No network route)}},

Android: Error: Failed to execute the network request.: Failed to execute the network request., message: null

Case 2: Wrong refresh token (just replaced refresh token with some dummy data)

iOS:
Error: RENEW_FAILED: The credentials renewal failed. CAUSE: Unknown or invalid refresh token., message: Token renew failed

Android

Code: An error occurred while trying to use the Refresh Token to renew the Credentials. 
message: An error occurred while trying to use the Refresh Token to renew the Credentials. 
details: {}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature has been asked for or suggested by the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions