I am using the Lock.swift (v2.3.1) and Auth0.Swift (v1.7.1) SDKs for iOS 9+. In the documentation for Auth0.Swift, it suggests that the class CredentialsManager
can be used to store the Credentials
object and retrieve it again later. This feature works correctly when I use Lock with OIDC conformance set to true. However, it does not behave as expected when OIDC conformance is set to false.
Below is a working example:
Lock
.classic()
.withConnections { (connections: inout ConnectionBuildable) in
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
.withOptions { (options: inout OptionBuildable) in
options.scope = "openid profile user_metadata app_metadata" // some custom scopes
options.oidcConformant = true
}
.onAuth { (credentials: Credentials) in
let credentialsManager = CredentialsManager(authentication: Auth0.authentication())
let isCredentialsStored = self.credentialsManager.store(credentials: credentials)
if isCredentialsStored {
print("Credentials saved: \(credentials.debugDescription)")
let isValid = self.credentialsManager.hasValid()
if isValid {
print("Valid!")
} else {
print("Invalid!")
}
credentialsManager.credentials { (error: CredentialsManagerError?, credentials: Credentials?) in
if let error = error {
print("Failed to instantly retrieve the credentials with error: \(error)")
}
}
}
}
Output ( oidcConformant = true
):
Credentials saved: <A0Credentials: 0x14d2a930>
Valid!
Output ( oidcConformant = false
):
Credentials saved: <A0Credentials: 0x15dc0a10>
Invalid!
Failed to instantly retrieve the credentials with error: noCredentials
Note that when oidcConformant = false
, the variable in the above example, isCredentialsStored
, still evaluates as true! However, the hasValid
and credentials
method in CredentialsManager
both fail.
Is there a reason why the credentials manager cannot retrieve a stored credential when OIDC conformance is set to false? How can I store the Credentials
object while using non-OIDC conformance?