Auth0.swift
Auth0.swift copied to clipboard
isNetworkError does not report case where Wifi + Mobile Data is off
Checklist
- [X] The issue can be reproduced in the Auth0.swift sample app (or N/A).
- [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [X] I have looked into the API documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
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
- Log in with a user on a physical device
- Turn off Mobile Data + Wifi
- Call
CredentialsManager.credentials(minTTL:)with a token that triggers theoauth/tokenendpoint - Notice the returned error, and
isNetworkErrorbeingfalse
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
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.