Home / Market / restore credentials

restore credentials

Provides knowledge and workflows to implement Android's Restore Credentials feature using the androidx.credentials library. Use this skill to create, sign in with, and delete restore keys, enabling silent user sign-in on new devices after a restore. It covers version compatibility, dependencies, server-side prerequisites, and the complete client-side implementation for creating, retrieving, and clearing restore keys.

skill★ 108451219 dlskills.shApache-2.0Install in CosmosUpstream Source

Documentation & Preview

--- name: restore-credentials description: Provides knowledge and workflows to implement Android's Restore Credentials feature using the androidx.credentials library. Use this skill to create, sign in with, and delete restore keys, enabling silent user sign-in on new devices after a restore. It covers version compatibility, dependencies, server-side prerequisites, and the complete client-side implementation for creating, retrieving, and clearing restore keys. license: Complete terms in LICENSE.txt metadata: author: Google LLC last-updated: '2026-09-14' keywords:

---

Fundamentals

The objective is to implement the Restore Credentials feature through the Android Credential Manager API (androidx.credentials). This allows apps that use or are integrating Credential Manager to silently log users back in when they restore their app on a new device. Restore Credentials operates independently of the app's primary authentication method (passwords, passkeys, federated sign-in) and requires no UI changes to existing sign-in flows.

Scope

Crucial: This skill focuses exclusively on the Android client-side integration. It does not implement the server-side cryptographic validation logic. The developer must be reminded of this and the Points to inform the developer about after implementation is done.

Implementation Guidelines

When instructed to implement Restore Credentials on a developer's application, remember the following:

  1. Before the implementation, you MUST read and understand the [Two-Tier

Restoration Architecture](#two-tier-restoration-architecture) and review the DOs and DON'Ts.

  1. After the implementation, you MUST present the developer with the Backend Guidelines as a reminder for their backend setup. It is important that you remind the developer that they still have to implement the backend.

Two-Tier Restoration Architecture

To enable a resilient sign-in experience, retrieve credentials through a

two-tier architecture:

  1. Tier 1 (Primary - Background): Executes automatically during device setup using the app's BackupAgent.onRestoreFinished() callback. This provides an invisible restoration before the user opens the app for the first time, allowing background sync and notification delivery.
  2. Tier 2 (Secondary - Foreground): Runs in the Launcher Activity.onCreate() to catch failovers if background restoration didn't complete (example: dropped network, delayed restoration) or if allowBackup is disabled.

If allowBackup in the manifest is set to true, implement both. Otherwise, only implement tier 2 (Foreground Restoration). Do NOT change the value of allowBackup in the manifest.

If you added a BackupAgent to the app, you MUST also set android:fullBackupOnly="true" in the manifest. Do NOT do this if there already existed a BackupAgent in the app before your implementation.

DOs and DON'Ts

DO:

DON'T:

Implementation Guide

Implement the Android client-side code by using the following guide. Follow it

step-by-step and don't implement any backend functionality, only remind the user of the Backend Guidelines once you're done.

Version compatibility

Credential Manager's Restore Credentials works on devices running Android 9 (API level 28) and higher, Google Play services (GMS) core version 24220000 or higher, and version 1.5.0 or higher of the androidx.credentials library.

Prerequisites

Set up a relying party server similar to the server for passkeys. If you already have a server set up to handle authentication with passkeys, use the same server-side implementation for restore keys.

> [!NOTE] > Note: While the server-side implementation is the same for passkeys and restore keys, your client-side app can support restore keys without supporting passkeys. Because restore keys work independently of the authentication method in your app (for example, passwords or Sign in with Google), you don't need to make any additional changes to the existing authentication methods in your app's code.

Dependencies

Add the following dependencies to your app module's build.gradle file:

Kotlin

dependencies {
    implementation("androidx.credentials:credentials:1.7.0-alpha03")
    implementation("androidx.credentials:credentials-play-services-auth:1.7.0-alpha03")
}

Groovy

dependencies {
    implementation "androidx.credentials:credentials:1.7.0-alpha03"
    implementation "androidx.credentials:credentials-play-services-auth:1.7.0-alpha03"
}

Restore Credentials is available from version 1.5.0 and higher of the androidx.credentials library. However, it's recommended to use the latest stable versions of the dependencies where possible.

> [!NOTE] > Note: The Restore Credentials feature works regardless of whether allowBackup is set in the manifest.

Overview

  1. Create a restore key: To create a restore key, complete the following steps:
  2. Instantiate Credential Manager: Create a CredentialManager object.
  3. Get credential creation options from the app server: Send the client app the details required to create the restore key from your app server.
  4. Create the restore key: Create a restore key for the user's account if the user is signed in to your app.
  5. Handle the credential creation response: Send the credentials from your client app to your app server for processing, and handle any exceptions.
  6. Sign in with a restore key: To sign in with a restore key, complete the following steps:
  7. Get credential retrieval options from the app server: Send the client app the details required to retrieve the restore key from your app server.
  8. Get the restore key: Request the restore key from Credential Manager when the user sets up a new device. This lets the user sign in without additional input.
  9. Handle the credential retrieval response: Send the restore key from the client app to the app server to sign in the user.
  10. Delete a restore key.

Create a restore key

Your app should cover all cases of a user signing in to ensure active users have a restore key created. Create the restore key in the following scenarios:

To optimize performance and avoid the overhead of creating or checking for a restore credential on every single login, set a boolean flag or a credential creation timestamp in local storage, such as has_synced_restore_credential, to track whether the key has already been created.

> [!NOTE] > Note: A restore key is tied to an application's unique package name. If your organization's main app and sub-apps have different package names, create a separate restore key for each app.

Instantiate Credential Manager

Use your app's activity context to instantiate a CredentialManager object.

// Use your app or activity context to instantiate a client instance of // CredentialManager. private val credentialManager = CredentialManager.create(context)

Get credential creation options from your app server

Use a FIDO-compliant library in your app server to send your client app the information required to create the restore credential, such as information about the user, the app, and additional configuration properties. For more information about the server-side implementation, see Server-side guidance.

Create the restore key

After parsing the public key creation options sent by the server, create a restore key by wrapping these options in a CreateRestoreCredentialRequest object and calling the createCredential()) method with the CredentialManager object.

// createRestoreRequest contains th