Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

isNetworkError does not report case where Wifi + Mobile Data is off #822

Closed
6 tasks done
lordzsolt opened this issue Jan 11, 2024 · 1 comment · Fixed by #847
Closed
6 tasks done

isNetworkError does not report case where Wifi + Mobile Data is off #822

lordzsolt opened this issue Jan 11, 2024 · 1 comment · Fixed by #847
Labels
bug This points to a verified bug in the code

Comments

@lordzsolt
Copy link
Contributor

lordzsolt commented Jan 11, 2024

Checklist

Description

When I turn off Wifi + Mobile Data, and I call oauth/token through Auth0.swift, I receive the following error:

Unhandled error happened: The credentials renewal failed. CAUSE: Unable to complete the operation. CAUSE: Error Domain=NSURLErrorDomain Code=-1020 "A data connection is not currently allowed."

AuthenticationError.isNetworkError will report this as false, because:

Error code -1020 is equivalent to .dataNotAllowed which is not in the list of networkErrorCodes.


Interestingly, if I put the phone into airplane mode, I receive .notConnectedToInternet and this is reported as network error... 🤯


What is the intended purpose of isNetworkError?

  • I was intending to use it to distinguish between unknown errors and network errors.

Reproduction

  1. Log in with a user on a physical device
  2. Turn off Mobile Data + Wifi
  3. Call CredentialsManager.credentials(minTTL:) with a token that triggers the oauth/token endpoint
  4. Notice the returned error, and isNetworkError being false

Additional context

No response

Auth0.swift version

2.5.0

Platform

iOS

Platform version(s)

16.1.1

Xcode version

15.0

Package manager

Cocoapods

@lordzsolt lordzsolt added the bug This points to a verified bug in the code label Jan 11, 2024
@Widcket
Copy link
Contributor

Widcket commented Jan 11, 2024

Hi @lordzsolt, thanks for raising this.

.dataNotAllowed should indeed be on the list of networkErrorCodes. If you raise a PR adding it I'll happily review it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants