GetCustomCredentialOption


open class GetCustomCredentialOption : 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(
    type: String,
    requestData: Bundle,
    candidateQueryData: Bundle,
    isSystemProviderRequired: Boolean,
    isAutoSelectAllowed: Boolean,
    allowedProviders: Set<ComponentName>
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

GetCustomCredentialOption(
    type: String,
    requestData: Bundle,
    candidateQueryData: Bundle,
    isSystemProviderRequired: Boolean,
    isAutoSelectAllowed: Boolean,
    allowedProviders: Set<ComponentName>,
    typePriorityHint: Int
)

Allows extending custom versions of GetCredentialOptions for unique use cases.

Inherited properties

From androidx.credentials.CredentialOption
Set<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)

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

Boolean

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

Boolean

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

Bundle

the request data in the Bundle format

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)

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

Public constructors

GetCustomCredentialOption

Added in 1.2.0
GetCustomCredentialOption(
    type: String,
    requestData: Bundle,
    candidateQueryData: Bundle,
    isSystemProviderRequired: Boolean,
    isAutoSelectAllowed: Boolean = false,
    allowedProviders: Set<ComponentName> = emptySet()
)

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
type: String

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

requestData: Bundle

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)

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

isSystemProviderRequired: Boolean

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

isAutoSelectAllowed: Boolean = false

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

allowedProviders: Set<ComponentName> = emptySet()

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
GetCustomCredentialOption(
    type: String,
    requestData: Bundle,
    candidateQueryData: Bundle,
    isSystemProviderRequired: Boolean,
    isAutoSelectAllowed: Boolean = false,
    allowedProviders: Set<ComponentName> = emptySet(),
    typePriorityHint: Int = PRIORITY_DEFAULT
)

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
type: String

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

requestData: Bundle

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)

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

isSystemProviderRequired: Boolean

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

isAutoSelectAllowed: Boolean = false

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

allowedProviders: Set<ComponentName> = emptySet()

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)

typePriorityHint: Int = PRIORITY_DEFAULT

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