CreateCredentialRequest


abstract class CreateCredentialRequest

Known direct subclasses
CreateCustomCredentialRequest

Base custom create request class for registering a credential.

CreatePasswordRequest

A request to save the user password credential with their password provider.

CreatePublicKeyCredentialRequest

A request to register a passkey from the user's public key credential provider.

CreateRestoreCredentialRequest

A request to create a restore credential used for app restore purpose.


Base request class for registering a credential.

An application can construct a subtype request and call CredentialManager.createCredential to launch framework UI flows to collect consent and any other metadata needed from the user to register a new user credential.

Summary

Nested types

Information that may be used for display purposes when rendering UIs to collect the user consent and choice.

Public companion functions

CreateCredentialRequest

Parses the request into an instance of CreateCredentialRequest.

CreateCredentialRequest
@RequiresApi(value = 23)
createFrom(
    type: String,
    credentialData: Bundle,
    candidateQueryData: Bundle,
    requireSystemProvider: Boolean,
    origin: String?
)

Attempts to parse the raw data into one of CreatePasswordRequest, CreatePublicKeyCredentialRequest, and CreateCustomCredentialRequest.

Public properties

Bundle

the partial request data in the Bundle format that will be sent to the provider during the initial candidate query stage, which should not contain sensitive user credential information (note: bundle keys in the form of androidx.credentials.* are reserved for internal library use)

Bundle

the request data in the Bundle format

CreateCredentialRequest.DisplayInfo

the information to be displayed on the screen

Boolean

whether a create option will be automatically chosen if it is the only one available to the user

Boolean

true if must only be fulfilled by a system provider and false otherwise

String?

the origin of a different application if the request is being made on behalf of that application (Note: for API level >=34, setting a non-null value for this parameter will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present)

Boolean

true if you prefer the operation to return immediately when there is no available passkey registration offering instead of falling back to discovering remote options, and false (preferred by default) otherwise

String

the credential type determined by the credential-type-specific subclass (e.g. the type for CreatePasswordRequest is PasswordCredential.TYPE_PASSWORD_CREDENTIAL and for CreatePublicKeyCredentialRequest is PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL)

Public companion functions

createFrom

Added in 1.5.0-beta01
@RequiresApi(value = 34)
fun createFrom(request: CreateCredentialRequest): CreateCredentialRequest

Parses the request into an instance of CreateCredentialRequest.

It is recommended to construct a CreateCredentialRequest by directly instantiating a CreateCredentialRequest subclass, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.

Parameters
request: CreateCredentialRequest

the framework CreateCredentialRequest object

createFrom

Added in 1.5.0-beta01
@RequiresApi(value = 23)
fun createFrom(
    type: String,
    credentialData: Bundle,
    candidateQueryData: Bundle,
    requireSystemProvider: Boolean,
    origin: String? = null
): CreateCredentialRequest

Attempts to parse the raw data into one of CreatePasswordRequest, CreatePublicKeyCredentialRequest, and CreateCustomCredentialRequest.

It is recommended to construct a CreateCredentialRequest by directly instantiating a CreateCredentialRequest subclass, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.

Parameters
type: String

matches CreateCredentialRequest.type

credentialData: Bundle

matches CreateCredentialRequest.credentialData, the request data in the Bundle format; this should be constructed and retrieved from the a given CreateCredentialRequest itself and never be created from scratch

candidateQueryData: Bundle

matches CreateCredentialRequest.candidateQueryData, the partial request data in the Bundle format that will be sent to the provider during the initial candidate query stage; this should be constructed and retrieved from the a given CreateCredentialRequest itself and never be created from scratch

requireSystemProvider: Boolean

whether the request must only be fulfilled by a system provider

origin: String? = null

the origin of a different application if the request is being made on behalf of that application

Public properties

candidateQueryData

Added in 1.2.0
val candidateQueryDataBundle

the partial request data in the Bundle format that will be sent to the provider during the initial candidate query stage, which should not contain sensitive user credential information (note: bundle keys in the form of androidx.credentials.* are reserved for internal library use)

credentialData

Added in 1.2.0
val credentialDataBundle

the request data in the Bundle format

displayInfo

Added in 1.2.0
val displayInfoCreateCredentialRequest.DisplayInfo

the information to be displayed on the screen

isAutoSelectAllowed

Added in 1.2.0
val isAutoSelectAllowedBoolean

whether a create option will be automatically chosen if it is the only one available to the user

isSystemProviderRequired

Added in 1.2.0
val isSystemProviderRequiredBoolean

true if must only be fulfilled by a system provider and false otherwise

origin

Added in 1.2.0
val originString?

the origin of a different application if the request is being made on behalf of that application (Note: for API level >=34, setting a non-null value for this parameter will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present)

preferImmediatelyAvailableCredentials

Added in 1.5.0-beta01
val preferImmediatelyAvailableCredentialsBoolean

true if you prefer the operation to return immediately when there is no available passkey registration offering instead of falling back to discovering remote options, and false (preferred by default) otherwise

type

Added in 1.2.0
val typeString

the credential type determined by the credential-type-specific subclass (e.g. the type for CreatePasswordRequest is PasswordCredential.TYPE_PASSWORD_CREDENTIAL and for CreatePublicKeyCredentialRequest is PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL)