GetCredentialRequest


class GetCredentialRequest


Encapsulates a request to get a user credential.

An application can construct such a request by adding one or more types of CredentialOption, and then call CredentialManager.getCredential to launch framework UI flows to allow the user to consent to using a previously saved credential for the given application.

Summary

Nested types

A builder for GetCredentialRequest.

Public companion functions

GetCredentialRequest
@RequiresApi(value = 34)
@Discouraged(message = "It is recommended to construct a GetCredentialRequest by directly instantiating a GetCredentialRequest")
createFrom(request: GetCredentialRequest)

Parses the request into an instance of GetCredentialRequest.

GetCredentialRequest
@Discouraged(message = "It is recommended to construct a GetCredentialRequest by directly instantiating a GetCredentialRequest")
createFrom(
    credentialOptions: List<CredentialOption>,
    origin: String?,
    metadata: Bundle
)

Parses the raw data into an instance of GetCredentialRequest.

Bundle
@Discouraged(message = "It should only be used by OEM services and library groups")
getRequestMetadataBundle(request: GetCredentialRequest)

Returns the request metadata as a Bundle.

Public constructors

GetCredentialRequest(
    credentialOptions: List<CredentialOption>,
    origin: String?,
    preferIdentityDocUi: Boolean,
    preferUiBrandingComponentName: ComponentName?,
    preferImmediatelyAvailableCredentials: Boolean
)

Public properties

List<CredentialOption>

the list of CredentialOption from which the user can choose one to authenticate to the app

String?

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

Boolean

the value which signals if the UI should be tailored to display an identity document like driver license etc.

Boolean

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

ComponentName?

a service ComponentName from which the Credential Selector UI will pull its label and icon to render top level branding.

Public companion functions

createFrom

Added in 1.5.0-alpha05
@RequiresApi(value = 34)
@Discouraged(message = "It is recommended to construct a GetCredentialRequest by directly instantiating a GetCredentialRequest")
fun createFrom(request: GetCredentialRequest): GetCredentialRequest

Parses the request into an instance of GetCredentialRequest.

Parameters
request: GetCredentialRequest

the framework GetCredentialRequest object

createFrom

@Discouraged(message = "It is recommended to construct a GetCredentialRequest by directly instantiating a GetCredentialRequest")
fun createFrom(
    credentialOptions: List<CredentialOption>,
    origin: String?,
    metadata: Bundle
): GetCredentialRequest

Parses the raw data into an instance of GetCredentialRequest.

Parameters
credentialOptions: List<CredentialOption>

matches GetCredentialRequest.credentialOptions

origin: String?

matches GetCredentialRequest.origin

metadata: Bundle

request metadata serialized as a Bundle using getRequestMetadataBundle

getRequestMetadataBundle

Added in 1.5.0-alpha05
@Discouraged(message = "It should only be used by OEM services and library groups")
fun getRequestMetadataBundle(request: GetCredentialRequest): Bundle

Returns the request metadata as a Bundle.

Note: this is not the equivalent of the complete request itself. For example, it does not include the request's credentialOptions or origin.

Public constructors

GetCredentialRequest

GetCredentialRequest(
    credentialOptions: List<CredentialOption>,
    origin: String? = null,
    preferIdentityDocUi: Boolean = false,
    preferUiBrandingComponentName: ComponentName? = null,
    preferImmediatelyAvailableCredentials: Boolean = false
)
Parameters
credentialOptions: List<CredentialOption>

the list of CredentialOption from which the user can choose one to authenticate to the app

origin: String? = null

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)

preferIdentityDocUi: Boolean = false

the value which signals if the UI should be tailored to display an identity document like driver license etc

preferUiBrandingComponentName: ComponentName? = null

a service ComponentName from which the Credential Selector UI will pull its label and icon to render top level branding (Note: your app must have the permission android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS to specify this, or it would not take effect; also this bit may not take effect for Android API level 33 and below, depending on the pre-34 provider(s) you have chosen

preferImmediatelyAvailableCredentials: Boolean = false

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

Public properties

credentialOptions

Added in 1.2.0
val credentialOptionsList<CredentialOption>

the list of CredentialOption from which the user can choose one to authenticate to the app

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

preferIdentityDocUi

Added in 1.2.0
val preferIdentityDocUiBoolean

the value which signals if the UI should be tailored to display an identity document like driver license etc.

preferImmediatelyAvailableCredentials

Added in 1.5.0-alpha05
val preferImmediatelyAvailableCredentialsBoolean

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

preferUiBrandingComponentName

Added in 1.2.0
val preferUiBrandingComponentNameComponentName?

a service ComponentName from which the Credential Selector UI will pull its label and icon to render top level branding. Your app must have the permission android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS to specify this, or it would not take effect. Notice that this bit may not take effect for Android API level 33 and below, depending on the pre-34 provider(s) you have chosen.