Backup
Backups allow you to save and restore the user's Keyless account. This is useful to give the users the ability to restore their account if the app is deleted.
After each authentication it is possible to fetch the
backupData
and the backupKey
and push them into your backup system. It could be Google Drive, iCloud or your cloud.
Each backup is encrypted with aes-gcm
using the backupKey
as symmetric key.The
backupData
and backupKey
are required to restore an account with Keyless. Save the Keyless backup info in a secure data storeAndroid
iOS
val configuration = AuthenticationConfiguration.builder
.retrievingBackup()
.build()
Keyless.authenticate(
authenticationConfiguration = configuration,
onCompletion = { authResult ->
when (authResult) {
is Keyless.KeylessResult.Success -> {
// use the backup
val backup: KeylessBackup? = authResult.value.backup
}
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
}
}
)
let authenticationConfiguration = Keyless.AuthenticationConfiguration.builder
.retrievingBackup()
.build()
Keyless.authenticate(authenticationConfiguration: authenticationConfiguration) { result in
switch result {
case .success(let authenticationSuccess):
// Handle your backup system logic
print("Retrieve data for backup successful")
print("Backup data: \(authenticationSuccess.backup?.data)")
print("Backup key: \(authenticationSuccess.backup?.key)")
case .failure(let error):
// Handle error and display an error to the user.
print("Retrieve data for backup failed with error: \(error.message)")
}
}
It is possible to restore the user account providing the
backupData
and the backupKey
to the Keyless SDK.Android
iOS
val configuration = EnrollmentConfiguration.builder
.withBackup(
backupKey = backupKey,
backupData = backupData
)
.build()
Keyless.enroll(
enrollmentConfiguration = configuration,
onCompletion = { result ->
when (result) {
is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "Enroll success - userId ${result.value.keylessId}")
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Enroll failure - error code ${result.error.code}")
}
})
let enrollmentConfiguration = Keyless.EnrollmentConfiguration.builder
.withBackup(Keyless.Backup(data: backupData, key: backupKey))
.build()
Keyless.enroll(enrollmentConfiguration: enrollmentConfiguration) { result in
switch result {
case .success(let enrollmentSuccess):
print("Enrollment from backup finished successfully")
case .failure(let error):
print("Enrollment from backup finished with error: \(error.message)")
}
}
Using the
withBackup
method it is possible to pass the object required to restore a backup.Last modified 9mo ago