Use the shouldRetrieveTemporaryState parameter of the BiomEnrollConfig or BiomAuthConfig depending if you want to retrieve the temporary state during enrollment or authencation flows.
Dunring the enrollment flow:
val enrollConfig =BiomEnrollConfig(shouldRetrieveTemporaryState =true)Keyless.enroll( configuration = enrollConfig, onCompletion = { result ->when (result) {is Keyless.KeylessResult.Success -> {val temporaryState = result.value.temporaryState// store the temporary state on your backend to recover the account in the future }is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "error code ${result.error.code}") } })
During the authentication flow:
val authConfig =BiomAuthConfig(shouldRetrieveTemporaryState =true)Keyless.authenticate( configuration = authConfig, onCompletion = { result ->when (result) {is Keyless.KeylessResult.Success -> {val temporaryState = result.value.temporaryState// store the temporary state on your backend to recover the account in the future }is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "error code ${result.error.code}") } })
During the enrollment flow:
let enrollConfig =BiomEnrollConfig(shouldRetrieveTemporaryState:true)Keyless.enroll( configuration: enrollConfig, onCompletion: { result inswitch result {case .success(let enrollSuccess):let temporaryState = enrollSuccess.temporaryState// store the temporary state on your backend to recover the account in the futurecase .failure(let error): print("error code: \(error.code) } })
During the authentication flow:
let authConfig =BiomAuthConfig(shouldRetrieveTemporaryState:true)Keyless.authenticate( configuration: authConfig, onCompletion: { result inswitch result {case .success(let authSuccess):let temporaryState = authSuccess.temporaryState// store the temporary state on your backend to recover the account in the futurecase .failure(let error): print("error code: \(error.code) } })
Recover from temporary state
Pass the temporary state during the enrollment flow to recover the account. The temporary state is the one you obtained and stored securely in the previous step.
When enrolling from the temporary state, Keyless shows the authentication UI to users. In the past users already went through the enrollment "onboarding" flow, we can reduce the friction in account recovery performing the authentication flow.
For technical reasons developers need to call Keyless.enroll instead of Keyless.authenticate even if the UI is the one from authentication flow.