{% setvar book_path %}/android/reference/kotlin/_book.yaml{% endsetvar %} {% include "/android/_dackka-meta-tags.html" %}

RestoreCredentialClient

{% setvar page_path %}com/google/android/gms/auth/blockstore/restorecredential/RestoreCredentialClient.html{% endsetvar %} {% setvar doc_root_path %}/android/reference{% endsetvar %} {% setvar can_switch %}1{% endsetvar %} {% include "android/_kotlin_switcher2.md" %}

@DoNotMock(value = "Use canonical fakes instead")
interface RestoreCredentialClient : HasApiKey


The interface for clients to access Restore Credential API. If you are trying to use the Restore API in your apps, you should use the AndroidX equivalent API, instead of using this API directly.

Summary

Public functions

Task<Boolean>

Returns a Task which asynchronously deletes the restore credential, with a Boolean result representing whether credential was deleted.

Task<CreateRestoreCredentialResponse>

Returns a Task which asynchronously creates a new public key credential with the provided CreateRestoreCredentialRequest and returns the public key.

Task<GetRestoreCredentialResponse>

Returns a Task which asynchronously returns the restore credential by signing the previously-stored private key.

Public functions

clearRestoreCredential

fun clearRestoreCredential(request: ClearRestoreCredentialRequest): Task<Boolean>

Returns a Task which asynchronously deletes the restore credential, with a Boolean result representing whether credential was deleted.

If no credential were found to delete, the task succeeds with a true return value.

createRestoreCredential

fun createRestoreCredential(request: CreateRestoreCredentialRequest): Task<CreateRestoreCredentialResponse>

Returns a Task which asynchronously creates a new public key credential with the provided CreateRestoreCredentialRequest and returns the public key.

The private key is stored locally. It is transferred to a new device during the device-to-device restore if a google account is also transferred.

The data will be backed up to the cloud in the next periodic sync. Cloud backup data is transferred to a new device during the cloud restore using Google's Backup & Restore services.

Only a single restore credential will be stored at a time. Subsequent calls will override the existing restore credential.

If the restore credential creation is successful, the public key will be returned as a registration response json.

Throws
InvalidArgumentException

if request is null or invalid.

getRestoreCredential

fun getRestoreCredential(request: GetRestoreCredentialRequest): Task<GetRestoreCredentialResponse>

Returns a Task which asynchronously returns the restore credential by signing the previously-stored private key.

The private key may have been written on the same device or may have been transferred during the device setup.

Use this API to seamlessly sign-in users to your app on a new device.

If no restore credential is found, returns an empty credential. Note that the data may be cleared by Google Play services on certain user actions (for example, if a user clears their app storage).

If a restore credential is found, it will be signed with the request data and returned as a registration response json.

Throws
InvalidArgumentException

if request is null or it contains invalid request.