GetCustomCredentialOption


public class GetCustomCredentialOption extends CredentialOption


Allows extending custom versions of GetCredentialOptions for unique use cases.

If you get a GetCustomCredentialOption instead of a type-safe option class such as GetPasswordOption, GetPublicKeyCredentialOption, etc., then you should check if you have any other library at interest that supports this custom type of credential option, and if so use its parsing utilities to resolve to a type-safe class within that library.

Note: The Bundle keys for requestData and candidateQueryData should not be in the form of androidx.credentials.* as they are reserved for internal use by this androidx library.

The typePriorityHint bit helps decide where the credential will be displayed on the selector. It is used with more importance than signals like 'last recently used' but with less importance than other signals, such as the ordering of displayed accounts. It is expected to be one of the defined CredentialOption.PRIORITY_* constants. By default, GetCustomCredentialOption will have CredentialOption.PRIORITY_DEFAULT, GetPasswordOption will have CredentialOption.PRIORITY_PASSWORD_OR_SIMILAR and GetPublicKeyCredentialOption will have CredentialOption.PRIORITY_PASSKEY_OR_SIMILAR. It is expected that GetCustomCredentialOption types will remain unchanged unless strong reasons arise and cannot ever have CredentialOption.PRIORITY_PASSKEY_OR_SIMILAR. Given passkeys prevent many security threats that other credentials do not, we enforce that nothing is shown higher than passkey types in order to provide end users with the safest credentials first. See the spec here for more information on passkeys.

Summary

Public constructors

GetCustomCredentialOption(
    @NonNull String type,
    @NonNull Bundle requestData,
    @NonNull Bundle candidateQueryData,
    boolean isSystemProviderRequired,
    boolean isAutoSelectAllowed,
    @NonNull Set<@NonNull ComponentName> allowedProviders
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

GetCustomCredentialOption(
    @NonNull String type,
    @NonNull Bundle requestData,
    @NonNull Bundle candidateQueryData,
    boolean isSystemProviderRequired,
    boolean isAutoSelectAllowed,
    @NonNull Set<@NonNull ComponentName> allowedProviders,
    int typePriorityHint
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

Inherited methods

From androidx.credentials.CredentialOption
final @NonNull Set<@NonNull ComponentName>

a set of provider service ComponentName allowed to receive this option (Note: a SecurityException will be thrown if it is set as non-empty but your app does not have android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS; empty means every provider is eligible; for API level < 34, this property will not take effect and you should control the allowed provider via library dependencies)

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 will not contain sensitive user information

final @NonNull Bundle

the request data in the Bundle format

final @NonNull String

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

final int

sets the priority of this entry, which defines how it appears in the credential selector, with less precedence than account ordering but more precedence than last used time; see PriorityHints for more information

final boolean

whether a credential entry will be automatically chosen if it is the only one available option

final boolean

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

Public constructors

GetCustomCredentialOption

Added in 1.2.0
public GetCustomCredentialOption(
    @NonNull String type,
    @NonNull Bundle requestData,
    @NonNull Bundle candidateQueryData,
    boolean isSystemProviderRequired,
    boolean isAutoSelectAllowed,
    @NonNull Set<@NonNull ComponentName> allowedProviders
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

If you get a GetCustomCredentialOption instead of a type-safe option class such as GetPasswordOption, GetPublicKeyCredentialOption, etc., then you should check if you have any other library at interest that supports this custom type of credential option, and if so use its parsing utilities to resolve to a type-safe class within that library.

Note: The Bundle keys for requestData and candidateQueryData should not be in the form of androidx.credentials.* as they are reserved for internal use by this androidx library.

Parameters
@NonNull String type

the credential type determined by the credential-type-specific subclass generated for custom use cases

@NonNull Bundle requestData

the request data in the Bundle format, generated for custom use cases (note: bundle keys in the form of androidx.credentials.* and android.credentials.* are reserved for internal library usage)

@NonNull Bundle candidateQueryData

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 information (note: bundle keys in the form of androidx.credentials.* and android.credentials.* are reserved for internal library usage)

boolean isSystemProviderRequired

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

boolean isAutoSelectAllowed

defines if a credential entry will be automatically chosen if it is the only one available option, false by default

@NonNull Set<@NonNull ComponentName> allowedProviders

a set of provider service ComponentName allowed to receive this option (Note: a SecurityException will be thrown if it is set as non-empty but your app does not have android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS; for API level < 34, this property will not take effect and you should control the allowed provider via library dependencies)

GetCustomCredentialOption

Added in 1.5.0-beta01
public GetCustomCredentialOption(
    @NonNull String type,
    @NonNull Bundle requestData,
    @NonNull Bundle candidateQueryData,
    boolean isSystemProviderRequired,
    boolean isAutoSelectAllowed,
    @NonNull Set<@NonNull ComponentName> allowedProviders,
    int typePriorityHint
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

If you get a GetCustomCredentialOption instead of a type-safe option class such as GetPasswordOption, GetPublicKeyCredentialOption, etc., then you should check if you have any other library at interest that supports this custom type of credential option, and if so use its parsing utilities to resolve to a type-safe class within that library.

Note: The Bundle keys for requestData and candidateQueryData should not be in the form of androidx.credentials.* as they are reserved for internal use by this androidx library.

The typePriorityHint bit helps decide where the credential will be displayed on the selector. It is expected that GetCustomCredentialOption types will remain unchanged unless strong reasons arise and cannot ever have CredentialOption.PRIORITY_PASSKEY_OR_SIMILAR. Given passkeys prevent many security threats that other credentials do not, we enforce that nothing is shown higher than passkey types in order to provide end users with the safest credentials first. See the spec here for more information on passkeys.

Parameters
@NonNull String type

the credential type determined by the credential-type-specific subclass generated for custom use cases

@NonNull Bundle requestData

the request data in the Bundle format, generated for custom use cases (note: bundle keys in the form of androidx.credentials.* and android.credentials.* are reserved for internal library usage)

@NonNull Bundle candidateQueryData

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 information (note: bundle keys in the form of androidx.credentials.* and android.credentials.* are reserved for internal library usage)

boolean isSystemProviderRequired

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

boolean isAutoSelectAllowed

defines if a credential entry will be automatically chosen if it is the only one available option, false by default

@NonNull Set<@NonNull ComponentName> allowedProviders

a set of provider service ComponentName allowed to receive this option (Note: a SecurityException will be thrown if it is set as non-empty but your app does not have android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS; for API level < 34, this property will not take effect and you should control the allowed provider via library dependencies)

int typePriorityHint

sets the priority of this entry, which defines how it appears in the credential selector, with less precedence than account ordering but more precedence than last used time; see CredentialOption and CredentialOption for more information