auth0/Lock.swift

iOS SDK Offline authentication with WiFi

MysticMedia opened this issue · 5 comments

Hi,

We are using Auth0 iOS Siwft SDK into our app. Our app needs to authenticate user in both situation with and without internet connection. Everything is working fine however we are running into issue at offline authentication when device is connected to WiFi but there is no active internet connection. At that time Auth0 SDK keeps trying to connect to internet with no luck and not switching to offline auth method preventing user to proceed further.

Reproduction

Detail the steps taken to reproduce this error, and whether this issue can be reproduced consistently or if it is intermittent.

  • It can be reproduce everytime, Just have iOS device connected to WiFi with no internet connection and it will stuck into authenticating loop.

Version of Lock.swift used:

  • 1.0

Version of iOS:

  • iOS 11.0 and above

Version of Xcode:

  • 12.3

Hi @MysticMedia, an internet connection is required to log in. Once the user is logged in, you can store the credentials in your app and then on launch use the expiration timestamp to check if they're still valid. If the credentials are still valid, then you don't need to perform login again. This step does not require an internet connection.

Once the credentials expire, you can use the refresh token (use the offline_access scope to get one) to get new credentials and keep the user logged in.

Please check out the Auth0.swift User Sessions QuickStart to learn more. Does that help?

Here is some additional info.

After checking token expiry with function "credentialsManager.hasValid()", we are fetching current user's credentials using SDK's function

credentialsManager.credentials { error, credentials in
guard error == nil, let credentials = credentials else {
return callback(error)
}
self.credentials = credentials
callback(nil)
}

in this function it tries to connect to Internet and goes into loop.

@MysticMedia can you provide a video of the loop you're talking about? If the SDK can't reach Auth0's servers, then the data task should fail with an error.

Also, the request will only take place if the credentials have expired. What is your use case for wanting expired credentials?

Closing due to inactivity.