CreateCredentialRequest


public 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.


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 methods

static final @NonNull CreateCredentialRequest
@RequiresApi(value = 23)
createFrom(
    @NonNull String type,
    @NonNull Bundle credentialData,
    @NonNull Bundle candidateQueryData,
    boolean requireSystemProvider,
    String origin
)

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

final @NonNull 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)

final @NonNull Bundle

the request data in the Bundle format

final @NonNull CreateCredentialRequest.DisplayInfo

the information to be displayed on the screen

final 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)

final @NonNull 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)

final boolean

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

final boolean

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

final 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

Public methods

createFrom

Added in 1.3.0-alpha03
@RequiresApi(value = 23)
public static final @NonNull CreateCredentialRequest createFrom(
    @NonNull String type,
    @NonNull Bundle credentialData,
    @NonNull Bundle candidateQueryData,
    boolean requireSystemProvider,
    String origin
)

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

Parameters
@NonNull String type

matches CreateCredentialRequest.type

@NonNull Bundle credentialData

matches CreateCredentialRequest.credentialData

@NonNull Bundle candidateQueryData

matches CreateCredentialRequest.candidateQueryData

boolean requireSystemProvider

whether the request must only be fulfilled by a system provider

String origin

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

getCandidateQueryData

Added in 1.2.0
public final @NonNull Bundle getCandidateQueryData()

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)

getCredentialData

Added in 1.2.0
public final @NonNull Bundle getCredentialData()

the request data in the Bundle format

getDisplayInfo

Added in 1.2.0
public final @NonNull CreateCredentialRequest.DisplayInfo getDisplayInfo()

the information to be displayed on the screen

getOrigin

Added in 1.2.0
public final String getOrigin()

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)

getType

Added in 1.2.0
public final @NonNull String getType()

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)

isAutoSelectAllowed

Added in 1.2.0
public final boolean isAutoSelectAllowed()

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

isSystemProviderRequired

Added in 1.2.0
public final boolean isSystemProviderRequired()

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

preferImmediatelyAvailableCredentials

Added in 1.3.0-alpha03
public final boolean preferImmediatelyAvailableCredentials()

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