I am using Lock 2.0 with the iOS 13 simulator and saving credentials. It appears the credentials can’t be read or received. I haven’t tried this on device yet. I have the following code.
Lock
.classic()
.withOptions { options in
options.scope = “openid idToken profile offline_access”
options.audience = “https://test-brighloom-cantina.auth0.com/userinfo”
options.oidcConformant = true
options.logHttpRequest = true
options.logLevel = .all
}
.onAuth { [weak self] credentials in
guard let self = self else {
return
}
if !self.credentialsManager.store(credentials: credentials) {
handler(Swift.Result<Void, AuthenticationServiceError>.failure(.failedToSaveToken))
return
}
handler(Swift.Result<Void, AuthenticationServiceError>.success(()))
}
.onError { error in
handler(Swift.Result<Void, AuthenticationServiceError>.failure(.failedToGetToken))
}
.present(from: windowScene.windows[0].rootViewController!)
But if I quit my app and restart the call credentialsManager.hasValid() it always returns false. The query always returns nil when getting the string but there is no error. So anytime we check to see if we have valid credentials on startup we are shown the login dialog.
Your sample app doesn’t appear to be working on the device as well.
4 Likes
We’re having the same issue, only in the Simulator. Works as expected on device.
-
When user signs up, we do: credentialsManager.store(credentials: credentials)
and it returns true
. It’s supposed to have stored the credentials successfully in the keychain.
-
With our authenticated user, we bring our user to the Feed, where we perform a session check to make sure credentials are valid/not expired. At this point, credentials cannot be found! Returned error is noCredentials
.
Testing on:
Xcode 11.4 Beta 3
iPhone 11 (13.4) Simulator
Auth0 (1.22.1)
Lock (2.16.1)
Any remarks on this? Has it been reproduced?
Thanks
2 Likes
Hi there, I am experiencing the same error. Calling the credentialsManager.store(credentials)
returns true, when trying to load these via credentialsManager.credentials(withScope)
I am getting " noCredentials" error and no credentials, obviously.
The CredentialsManager implementation is using NSKeyedArchiver and NSKeyedUnarchiver to store and load data from the storage. The following piece of code
print("credentials", $0)
let data = NSKeyedArchiver.archivedData(withRootObject: $0)
print("data", data)
let credentials = NSKeyedUnarchiver.unarchiveObject(with: data) as? Credentials
print("credentials unarchived", credentials ?? "<none>")
provides this output:
credentials <A0Credentials: 0x600001e44b00>
data 2316 bytes
credentials unarchived <none>
Do I understand it right that the NSKeyedArchiver and NSKeyedUnarchiver can’t encode/decode the A0Credentials object? What can I do about it? Using Credentials object instead does not work either.
However, replacing the NSKeyedUnarchiver.unarchiveObject
with NSKeyedUnarchiver.unarchiveTopLevelObjectWithData
seems to decode the data well:
credentials unarchived Credentials(accessToken: "<REDACTED>", tokenType: "Bearer", idToken: "<REDACTED>", refreshToken: Optional("<REDACTED>"), expiresIn: 2023-02-19 21:08:26 +0000, scope: Optional("openid profile email address phone offline_access"), recoveryCode: nil)
I must have done something wrong.
Thank you, JP